showModal(), showAlert()
, etc., added in the function block.GetUsersList,
and you want to call this API on runtime, that is, whenever the JS Object function callAPI()
is executed. Your function may look as below:GetUsersList.run()
marks the function callAPI()
for asynchronous execution and hence callAPI
function is considered as async.User Listing
and have added a JS object with the function GetUserRole
which fetches the user’s role. You want that the query should be executed at the time of page load so that the logged-in user will be able to see the user listing. To get this working, you have to set the RUN ON PAGE LOAD configuration as YES for the GetUserRole
function. Once the configuration is in place, the function GetUserRole
will be executed whenever the app is loaded and the response generated by it will be displayed on the page.JSObjectName.asynFunctionName.data
. In this case, the on-page load is automatically set as true. You can explicitly change this setting to suit your logic in the Settings tab.{{JSObject.myFun.data}}
, at that time Appsmith marks the execution of that query/API on page load. You can modify the same by navigating to JSObject → Settings → RUN ON PAGE LOAD → Select No.JSObject5
that calls an API getUsers
. The getUsers
API call is embedded in the showData
function and generates a user listing.showData
to table widget Table1
by adding the below code in the Table Data
property available on the property pane of the Table widget.showData
function is called on page load, and Table1
displays the data.deletePermission
which calls an API that deletes the database’s permission. You would want to ensure that the user wants to delete permission, in which case, you would like to show a confirmation dialogue. The confirmation dialog ensures that the user wants to perform a delete action. A user can choose Yes to delete or can decline the same by choosing No. Thus Confirm Before Calling
comes in handy to protect against users accidentally running destructive operations.UserListing
which displays the data generated by the showUserListing
function of the DataLoader
JS object. The function generates a list of users.DataLoader
and add a function showUserListing
that checks whether the user is logged in or not._ The function will verify the below logic:GetUserList
API will be called, and the response will be generatedAnonymousUser
page.showUserListing
of JS Object - DataLoader to run on page load by selecting Yes.showUserListing
is marked for asynchronous execution by defining the async
keyword.GetUserList
API is executed:showUserListing
function is executed. The function determines whether the user is anonymous. You can use the property of a user object isAnonymous
to check the user's logged-in status.appsmith.user.isAnonymous
returns true
and redirects the user to the AnonymousUser
page and displays the message.You are not authorized to view user data.
appsmith.user.isAnonymous
returns false
and the logic is executed to verify if the logged-in user is an Appsmith user. If the user is an Appsmith user, GetUserList
API is called to fetch the user listing. The execution is completed, and the response is generated, displayed in the UserListing
table.