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:

  1. Select the sandbox you want to configure.

  2. Select Navigator > Application Composer > Mobile Application Setup.

  3. In the Application Feature pane, select Settings.

  4. Click Scripts Settings and enable the Enable Scripts option.

  5. Click Save in the top right-hand side of the Application Composer page.

  6. Click the Scripts tab on the Mobile Application Setup page.

  7. 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)

  8. Click the plus icon in the <Event Name> Scripts section.

  9. Enter the script name and description.

  10. (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.

  11. Click Create and create your script.

  12. Click Validate to check whether your script has any errors.

  13. 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

  • ActivityDescription

  • PrimaryContactId

  • __ORACO_StoreVisitType_Id_c

Account

  • PrimaryContactPartyId

  • URL

  • OwnerPartyId

__ORACO__OrderDSD_c

__ORACO__Comments_c