1. Home
  2. Docs
  3. NoCode-X Documentation
  4. Actions
  5. Variable scope

Variable scope


A variable is simply a named unit of data that is assigned a value. Its value can change, but its name will stay the same.

As detailed on the function call result page, many functions will create a variable at the end of their execution. For example, the Get answer of number field function stores the number it receives from the number component in a variable. You may need this variable as an argument in later function calls. Variables created by actions reside in the variable scope.


These variables can then be used in other function calls. They must be provided in the Arguments tab of an action. Click the input field to view all variables in the scope. An image of an example scope is shown at the bottom of this article. Make sure the variable you choose has the correct type. For example, if a function call requires you to pass a string, you must enter the name of a string variable.

Default variables in the scope

By default, the scope contains the following variables:

CurrentUser.userId: Current user idThe id of the current user.
CurrentUser.firstName: Current user firstnameThe first name of the current user.
CurrentUser.lastName: Current user lastNameThe last name of the current user.

These can only be used when a user is logged in. It this therefore recommended to only use them on authenticated pages or when necessary checks are in place.


The variable scope is best explained through an example. Let’s assume we are creating a form for users. At one point we ask the user to provide the number of pets they have. Evidently, we will represent this with a number field component. We want to add this number to a list.

We take the following steps:

  1. Create a new action for the number field component. This is explained in the Component actions article.
  2. Add a Get answer of a number field function call and select the number field component in the Arguments tab.
  3. The number entered by the user will be stored in a variable. We must name this variable in the Result tab. We have chosen Amount_of_pets. It is now part of the variable scope.
  4. Connect an Add to list function call to the one from from step 2. The result is shown in the image below.
  5. Select the list you want to add the number to.
  6. Choose the item (the number we just placed inside a variable) by clicking the Item input field with the scope option selected. Our number variable appears in the list. This is shown in the second image below.
  7. Finally, we must name the new list (with the pet’s age added to it) in the Result tab. Now we have created another variable, and the cycle continues.
The example of a number added to a list.
The list of variables in the scope. We must select the last one, "Amount_of_pets"

How can we help?