Field Level Scripting in Mobile Devices

2 minute read time.

All scripts need to consider where they are executed. Create and Validate scripts are executed on the server. This means that a screen in the mobile device when it submits data will see that data processed in the same way as a screen in the main desktop theme.

Note: The mobile screens will use different metadata screens to the main interface screens. For example in the main desktop theme when submitting an opportunity the screens used are

  • OpportunityWebPicker
  • OpportunityDetailBox
  • (OpportunityWaveDetailBox)
  • OpportunityStatusBox

But the mobile screen only uses

  • OpportunityDetailBox

You can see in the above lists of metadata screen that the OpportunityDetailBox is the only screen that is used in both the mobile and desktop themes. But the version of the OpportunityDetailBox for the mobile theme includes many more fields than the version of the same screen in the Desktop theme.

We can expect the Create scripts and the Validate scripts for the mobile theme because they are executed on the server to work. And they do.

Note: Create scripts and the Validate scripts do work in the Mobile Theme with the following warnings. Create scripts are focussed on changing the properties of fields such as the Caption or the DefaultValue. This assumes that these make sense within the context of the mobile theme as certain field types are rendered differently in the mobile theme as they are within the desktop theme. An example of is the Search Select Advanced fields where you can set a field's restrictors. This is a property that restricts the searched values for the current Search Select Advanced field.

See: http://help.sagecrm.com/on_premise/en/2018R3/administration/Content/Administrator/FC_ChangeDBFieldProps.htm?Highlight=ssa%20restrictors

But this can't be used in the mobile theme (because of the way the theme renders the screen) so instead, we have to make may changes to the file "ssarestrictors.js" here: C:\Program Files (x86)\Sage\CRM\CRM\WWWRoot\tablet\ssa

How to do that will need to be the subject of another article.

Now we can turn our attention to the Client Side scripting.

There are a number of points to realise here:

  1. The Mobile theme simplifies the interface. See: https://community.sagecrm.com/partner_community/b/hints_tips_and_tricks/archive/2018/09/06/how-the-mobile-theme-interface-is-generated.aspx
  2. This simplification includes such things as the Custom Content boxes of the screens being ignored. Custom Content is a very useful feature used frequently in customizations that use Client Side coding in the Desktop Theme. But it can not be used here.
  3. The libraries used are different. For example the JQuery files included in the Mobile interface are the Mobile versions. The Client Side API used in the Desktop Theme is not referenced. Neither are any fields that you may add into the location C:\Program Files (x86)\Sage\CRM\[installname]\WWWRoot\js\custom
  4. The fields are rendered differently in HTML. The Mobile Theme does not use the same element naming (in HTML) or ID system as the Desktop Theme.

All this means that you can use Client Side coding in the Mobile Themes but you will need to write the code very differently for the Mobile device and some things will not be possible. You can't expect code written for the Desktop to work in the Mobile Theme. Some features such as external libraries, custom content are not available and the naming (ID) convention used for the screen elements means that even plain old JavaScript cannot be written the same in the Mobile interface as it is in the Desktop interface.