Mobile Scripting
As an administrator, you can write custom scripts for the consumer goods application to support your business logic and requirements. You can add custom logic for selected events and objects in your offline mobile and tablet applications.
Extend Your Custom Logic with Scripts
Set up your app to match your business requirements by writing custom JavaScript, whether you're online or offline. Create scripts for any top-level object and trigger an event of your choice. For example, you can create a script that makes the product field mandatory when you create an opportunity. Here are the supported types of validations and rules:
-
Calculated fields: Indicates the field values for calculated fields
-
Field validations: Validates that field values are allowed on data entry
-
Action validations: Validates whether an action can be taken or not under certain conditions.
-
Mandatory fields: Conditionally makes the fields mandatory.
-
Read-only fields: Conditionally makes fields read-only.
How to Create a Script
You can create custom scripts for a specific object or for all objects. Here's how you create a custom script for a specific object:
-
Select the sandbox you want to configure.
-
Select
. -
In the Application Feature pane, select Settings.
-
Click Scripts Settings and enable the Enable Scripts option.
-
Click Save in the top right-hand side of the Application Composer page.
-
Click the Scripts tab on the Mobile Application Setup page.
-
Select the object you want to write a script for and then select the event that triggers your script. You can select one of these triggers:
-
On Create (triggers the script while creating a new record in the mobile app)
-
Before Save (triggers the script before saving the record)
-
On Field Value Change (triggers the script when you change the value of a field and then tap out of the field)
-
After Save (triggers the script after the app saves the record)
-
-
Click the plus icon in the <Event Name> Scripts section.
-
Enter the script name and description.
-
(Optional) If you want the script to work for a particular region, select the geographical region. The script works for those who have your selected regions as their country preference setting in your sales application.
Note:Remember, you can have only one script per region for an object and an event. For example, you can create a script for an opportunity, for the On Create trigger, for the UK region. To include a different region for the same object and event, create another script. For example, create a script for an opportunity, for the On Create trigger, for the US region.
To restrict your script to trigger for certain roles, specify these by writing a JavaScript.
-
Click Create and create your script.
-
Click Validate to check whether your script has any errors.
-
Click Save.
Supported Objects
Here is the list of standard and custom objects that support mobile scripting and different actions:
Object Name |
onCreate |
beforeSave |
afterSave |
onFieldValueChange |
---|---|---|---|---|
__ORACO__Inventory_C |
No |
Yes |
Yes |
Yes |
Activity |
Yes |
Yes |
Yes |
Yes |
__ORACO__ShoppingCartDSD_c |
No |
Yes |
Yes |
No |
__ORACO_RouteInventory_c |
No |
Yes |
Yes |
No |
__ORACO__InvoiceDSD_C |
No |
Yes |
Yes |
No |
__ORACO__InvoiceLineDSD |
No |
Yes |
Yes |
No |
Organization |
No |
Yes |
Yes |
Yes |
__ORACO__Document_c |
Yes |
Yes |
Yes |
No |
__ORACO__Expense_c |
Yes |
Yes |
Yes |
No |
__ORACO__InventoryAuditDSD_c |
No |
Yes |
Yes |
No |
__ORACO__InvAuditLineDSD_c |
No |
Yes |
Yes |
No |
__ORACO__InventoryReloadDSD_c |
No |
Yes |
Yes |
No |
__ORACO_InvReloadLineDSD_c |
No |
Yes |
Yes |
No |
__ORACO_RouteAssignHist_c |
No |
Yes |
Yes |
No |
__ORACO__RouteCheckInHist_c |
No |
Yes |
Yes |
No |
__ORACO__PaymentDSD_c |
Yes |
Yes |
Yes |
Yes |
__ORACO__PaymentLineDSD_c |
Yes |
Yes |
Yes |
|
__ORACO__MerchLocation_c |
Yes |
Yes |
Yes |
Yes |
__ORACO__ShipmentDSD_C |
No |
Yes |
Yes |
No |
__ORACO__OrderDSD_c |
No |
Yes |
Yes |
Yes |
__ORACO__OrderLineDSD_c |
No |
Yes |
Yes |
|
__ORACO__RoutePresettlement_C |
No |
Yes |
Yes |
No |
__ORACO__BankDeposit_c |
Yes |
Yes |
Yes |
Yes |
__ORACO__AccountTaskDetails_C |
No |
Yes |
Yes |
Yes |
The fields that support onFeildValueChange, are listed in this table:
Objects |
Fields |
---|---|
__ORACO_BankDeposit_c |
__ORACO__DepositDate_c |
__ORACO__Inventory_c |
__ORACO_MerchandisingLocation_Id_C |
Activity |
|
Account |
|
__ORACO__OrderDSD_c |
__ORACO__Comments_c |