Use a Server Action Library
A server action library is used by calling it from a solution. Two situations arise:
•If an Action Group of a server action library is designed to return a value to the calling solution, then the call is made via a Let action. This is because a Let action is defined with a variable which can be set to receive the result of the Action Group (see screenshot below). This variable can then be used inside the calling solution. The screenshot below shows a call to the ScanFolder Action Group of a server action library via a Let action. The Action Group result will be passed to the $FolderReadout variable of the calling solution.
•If the Action Group of the server action library is designed to carry out actions on the server (that is, independently of the calling solution and client device), then it will not have a return value to send to the calling solution. As a result, the Action Group needs only to be called at the point where it is needed; a Let action is not needed. In this case, simply drag the Action Group of the server action library to the point where it should be executed in the processing of an event's actions (see screenshot below).
Call the Action Group of a server action library
In a main solution, to set up a call to a server action library, do the following:
1.In the Files Pane, right-click the server action libraries item to access its context menu and select Add server action library (see screenshot below). Alternatively, use the menu command Refactor | Add server action library.
2.In the dialog that appears, browse for the server action library you want to add, select it, and click Open. The server action library will be added to the list of server action libraries and its Action Groups become available for calls.
3.Go to the Actions dialog of the event for which you want to use the server action library.
4.In the Actions dialog, all Action Groups of the added server action library will be available for use (see screenshot below). Note that the icon of Action Groups of server action libraries is different from that of local Action Groups.
5.Drag the Action Group to the location where you want to use it (see first screenshot at start of this topic).
6.After saving the solution, deploy it to the same MobileTogether Server as that to which the server action library has been deployed.
Important points
Note the following points about using Action Groups of server action libraries:
•You can add multiple server action libraries to a solution. The Action Groups of all the added server action libraries will automatically be available for use in the solution.
•If you modify a server action library in some significant way, such as by renaming a parameter, then you would need to modify the calling solution accordingly.
•If you modify a server action library, then you must reload the server action library in the Files Pane of the solution to make the modifications available in the calling solution and for simulations.
Example
In our example file, MainSolution.mtd, when the user selects a collection to scan in the Scan this folder combo box (see screenshot below), the following happens:
1.In the main (calling) solution, the collection name (Books, Films, or Music) is saved to the page source node $PERSISTENT/Root/UserSelection after it is selected in the solution's combo box (see above, first screenshot of this topic, and screenshot below).
2.The Action Group ScanFolder of the server action library ServerLibrary.mtd is called, and the user-selected collection name is passed as the value of the parameter $FolderToScan (see above, first screenshot of this topic).
3.The Action Group is executed and the folder corresponding to the collection name that was sent is scanned—by using the Read Folder action of the server action library's Action Group (see the topic Create a server action library).
4.The data tree that is generated as a result of the scan is returned to the calling solution, MainSolution.mtd, and stored in the calling solution's $FolderReadout variable (see above, first screenshot of this topic).
5.The data tree in $FolderReadout replaces the tree in $XML1.
6.The $XML1 page source is displayed as a table (screenshot below).