All Collections
Troubleshooting App Services functions
Troubleshooting App Services functions

Step-by-step troubleshooting App Services functions

Joao Boesso avatar
Written by Joao Boesso
Updated over a week ago

App Services Functions allow you to define and execute server-side logic for your application. You can call functions from your client applications as well as from other functions, and in JSON expressions throughout Realm. For more information, see App Services Functions.

If you experience issues executing a function, troubleshoot using the following steps:

1. Check the function on the Functions page in your Realm App:

2. Check the App Services Logs for entries related to the function:

  • You can enable Log Function Arguments in the function settings so that the arguments that a function receives are included in the log entry for each execution of the function.

  • You can log the parameters being passed to the function by adding console.log(<some parameters>) to your function code.

3. Test the function in the Console tab under the Function Editor:

  1. As the System User, click Console at the bottom and fill in the parameters for calling the function. Click Run.

  2. If you receive an error message, review the corresponding function code and address the issue based on the error you receive.

  3. If the function executes successfully, run the function again with a different user. Realm uses the System user by default when a user is not selected. This user has advanced privileges and automatically bypasses all rules. See Troubleshooting: Operations not permitted.

  4. Click Change User next to the Run button and select the Realm user you want to use, then click Run.

  5. If you encounter an error in this step, confirm you have granted the appropriate permission to the selected Realm user on the Rules page. If you are using Realm user metadata, ensure that the Realm user has all the necessary metadata.

For further help, contact MongoDB Support with the following information:

  • the name of the function with issues and the arguments you have passed in when executing the function

  • the full output of any informational or error messages logged upon encountering the issue

  • the date, time, and timezone of the first and the most recent occurrence of this issue

Did this answer your question?