canAjaxCallback

Description

Fires before every Ajax callback made to the server.

Discussion

Fires when an Ajax callback is made to the server. You can use this event to authorize the callback action. The e variable contains information about the callback you can reference in your Xbasic code.

If you want to prevent the Ajax callback from executing, set the e.authorized variable to .f.. If you do not set the e.authorized variable or set the value to .t., the callback will be executed.

Javascript can be returned from the function using the e.javascript variable.

The canAjaxCallback server-side event previously would only emit user-defined Javascript if the event denied permission for the callback. Now, user defined Javascript can be emitted even if the Ajax callback is allowed. This change was made in Alpha Anywhere build 4307 to support the Mobile Application with Persistent Login pattern.

Available Variables in the 'e' Object 

Several variables are available for reading or setting in the canAjaxCallback event. These variables are properties of the e object. The varialbes in the e object include:

Variable
Description
e.tmpl

The definition of the UX Component.

e.action

The Ajax callback action name.

e.callbackFunctionName

The name of the Ajax callback function that will b called.

Your code can set the following variables in the e object:

Variable
Description
e.javascript

Javascript to return to the client and execute.

e.authorized

A .t. or .f. value. If you do not set the value for this property, then authorized is assumed to be .t.. If authorized is .f., the callback action is not performed.

When working in Live Preview you can get the names of the simulated security groups using this variable: e.tmpl.Livepreview_permissions_friendly

When running in a real application, you can get the names of the security groups for the logged in using using: Context.Security.GetUserRoles()