Setting Up Custom RESTlets
Standard mobile processes use RESTlets to perform actions like obtaining, evaluating, or submitting data, among others. The mobile app displays data in page elements, submits them to NetSuite transactions, or uses them to validate your entries. If you use Mobile Printing, supported mobile processes use RESTlets to obtain print template data, evaluate printing rules, and perform printing tasks. Depending on your app requirements, you can create custom RESTlets that perform similar or other actions within mobile processes.
You can assign custom RESTlets to mobile actions in one of the following ways:
-
Forward Form and Submit Form action types include a script ID field and a deployment ID field in which you can directly map RESTlets. You can map custom RESTlets that validate data on the server side. For Submit Form actions, the custom RESTlet may also submit data to NetSuite transactions.
Standard mobile processes commonly use Forward Form and Submit Form action types on the On Click Action of button elements. Other page elements like data tables include the On Row Click Action, which may be assigned either of these actions. On the app, you can tap a button or a row to process data from the page and then navigate to another page. You can set up a custom RESTlet that performs additional data validation or submission along with the main action.
For more information, see Mobile Actions for Page Validation and Navigation.
-
SCM Mobile provides the Restlet type of mobile action on which you can set up custom RESTlets that perform actions within a mobile process. You can assign Restlet mobile actions to the following:
-
On Load Action of a page or page element
You can assign Restlet mobile actions to the On Load Action to perform tasks on mobile pages or load data for page elements. You can load data for new fields, popup messages, dropdown list options, and additional table columns, among others.
Note:Field elements like a Text Box or Dropdown include fields in which you can directly set up values or a source record. For more dynamic values or to obtain data from multiple sources, you can set up a RESTlet in the On Load Action instead.
Mobile pages have an After Load Action and On Popup Close Action that you can set up. To view the list of action fields on pages, see Configuring Pages and Actions for Custom Mobile Processes.
-
On Click Action, On Select Action, or On Scan Action of a page element
Depending on the page element, you can set up Restlet actions that run when you click buttons, scan bar codes, or select data. To view other actions available for each page element, see Configuring Mobile Page Elements.
-
Before Action RESTlet or After Action RESTlet of a Forward Form or Submit Form action type
Forward Form and Submit Form action types include fields for the Before Action RESTlet and After Action RESTlet. If you add custom fields or columns to mobile pages of a process, you can assign a custom RESTlet that validates these fields in the Before Action RESTlet. For a custom RESTlet that submits data from your custom page elements, you can assign it to an After Action RESTlet. Along with validation of standard data or submission to associated NetSuite transactions, the app validates or submits your additional data.
For a sample customization that includes this setup, see Setting Up Additional Fields Through Mobile Customization.
-
-
If you use Mobile Printing, SCM Mobile provides the Print type of mobile action that includes the Before Print Action. You assign a custom RESTlet to this action to perform tasks that you want to run before the main Print action.
Standard Print buttons contain a preconfigured Restlet action for this event that obtains data for print templates. If you create custom print templates, edit the parameters of this Restlet action to set up the source of data added to templates.
The Print action includes the Get File Path Action that you can also edit or set up with a Restlet action. You can set it up with a custom RESTlet that generates labels or documents.
For more information, see Setting Up Print Button Actions.
To set up custom RESTlets:
-
Add your custom RESTlet to the mobile app’s folder in your file cabinet. To access the folder, follow this path: SuiteBundles > Bundle <SuiteApp ID> > src. You can create a new folder or choose an existing one within it for your custom RESTlet files. See Uploading Files to the File Cabinet. For information about SuiteApp IDs, see SCM Mobile Setup.
-
Create a script record from which you can upload, deploy, and release your RESTlet.
Be sure to take note of the script ID and deployment ID for your custom RESTlet.
For instructions, see Creating a Script Record.
-
After you deploy and release your RESTlet, set it up in a page or page element by doing the following:
-
Access the page or specific page element on which you want to set up the RESTlet.
Note:For standard mobile processes, you can set up custom RESTlets on some page elements through Mobile Configuration. To access page elements through Mobile Configuration, see Configuring Mobile Page Elements.
-
On the Mobile -Page page or Mobile -Page Element page, in the action field, you can edit the existing mobile action or add a new one.
You can choose an action field like an On Click Action or On Load Action. Page elements for standard processes include action fields like On Click Custom Action or On Row Click Custom Action.
-
On the Mobile – Action page, you can set up your custom RESTlet in an existing Submit Form or Forward Form type of action. You can enter the RESTlet’s script ID and deployment ID in the appropriate fields.
You can set the other fields on the Mobile – Action page, which vary depending on the action type. For instructions, see Customizing Mobile Actions.
-
-
On the Mobile – Action page, you can click the Input Parameters or Output Parameters subtab to set up parameters. To pass data from custom fields on the app to your RESTlet, add input parameters. To store the RESTlet’s response to the mobile state, you can add output parameters. You can assign conditions to any of your parameters.
To set up a new Restlet type of action, see the following example of settings for steps 3 and 4:
Example
You add a column to the items table to display the manufacturing part number (MPN) of an item within the PO Receiving process. You create a RESTlet that obtains the MPN from item records for the list of items on the purchase order being processed. To set up the RESTlet for the column through Mobile Configuration, create a Mobile – Custom Column Setup record. On this record, in the On Load Action field, add a mobile action. On the Mobile – Action page, set up a Restlet type of action by doing the following
-
In the Type field, select Restlet.
-
In the HTTP Method field, select POST.
-
In the Script ID and Deployment ID fields, enter the corresponding IDs for your custom RESTlet.
To set up the additional column, see Adding Columns Through Mobile Configuration.
After creating and saving a Restlet type of mobile action, add an input parameter that obtains the specific purchase order being processed. The app displays the list of items from the purchase order along with their MPN. To set up, on the Mobile – Input Parameter page, enter details in the following fields:
-
In the Name field, enter a unique name for the input parameter.
-
In the Value field, enter state:dataRecord:scriptParams:transactionInternalId, the path to the value from the mobile state. The transactionInternalid key in the state stores the internal ID of the purchase order being processed.
-
In the Key field, enter the key from the RESTlet that corresponds to the value that you set up.
The key-value pair for the input parameter passes the internal ID to the RESTlet to specify the purchase order from which to obtain the list of items.
For more information, see Adding Parameters to Mobile Actions.