Execute JavaScript from rules: Difference between revisions

Jump to navigation Jump to search
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Bridge TOC}}
{{Bridge TOC}}
The [[Resco platform]] offers two main options for adding [[business logic]] to your projects:
The [[Resco platform]] offers two main options for adding client-side [[business logic]] to your projects:
* [[Rules editor|Rules]] which represent the no-code approach for simpler use cases
* [[Rules editor|Rules]] which represent the no-code approach for simpler use cases
* [[Resco JavaScript Bridge]] that allows you to write custom scripts to modify UI, data, and access additional functions
* [[Resco JavaScript Bridge]] that allows you to write custom scripts to modify UI, data, and access additional functions
Line 6: Line 6:
The option to execute scripts directly from rules combines these two options. It aims to simplify writing JavaScript for Mobile CRM by removing the need for boilerplate code, and it should open a path for creating reusable JavaScript libraries with additional functionality for Resco mobile apps, e.g., additional math, date, or string operations, and also business logic.
The option to execute scripts directly from rules combines these two options. It aims to simplify writing JavaScript for Mobile CRM by removing the need for boilerplate code, and it should open a path for creating reusable JavaScript libraries with additional functionality for Resco mobile apps, e.g., additional math, date, or string operations, and also business logic.


{{Note|For now, this option is supported for form rules. Do not attempt to use the ExecuteJS function in other rules, for example, in views.|Warning}}
{{Note|For now, this option is supported for form rules and questionnaires. Do not attempt to use the ExecuteJS function in other rules, for example, in views.|Warning}}


== Offline HTML ==
== Offline HTML ==
Line 29: Line 29:
* The serialized MobileCRM.UI.EntityForm object is automatically passed as a parameter to the function. You cannot pass a custom input parameter.
* The serialized MobileCRM.UI.EntityForm object is automatically passed as a parameter to the function. You cannot pass a custom input parameter.
* The implementation supports also ''promises'' for asynchronous result return from functions.
* The implementation supports also ''promises'' for asynchronous result return from functions.
== Questionnaire specifics ==
The behavior of the ExecuteJS operator in questionnaire rules is similar to forms:
* It is supported for variables and also whenever you can enter a value; for example for Question.Value.
* In the first argument, simply select the value "IFrame". (Questionnaires don't have multiple tabs for selecting.)
[[File:Execute javascript in questionnaire rules.png|600px]]


== Example ==
== Example ==

Navigation menu