We have added "Pre Submit" rule in our form. It is getting invoked each time when we navigate through pages clicking "Continue" button. Below is the only code we have in "Click" rule of Continue button.
Please advise how we can check from where it is getting invoked and how we can invoke those kind of form rules in Click event of buttons.
You can call Form.fireRule to manually fire rules in you code.
If you put the line 'debugger;' at the top of your Pre Submit rule code, and turn on developer mode (F12 on Chrome), you can inspect the Call Stack to find out what is calling your Pre Submit code.
You could inspect the Form.dialogName property. If the rule is triggered by a click on 'Save and Close', it should contain 'saveconfirm', if it is triggered by a Submit it will be either undefined or an empty string, depending on previous activity.
You can access the dialogName property from inside a pre-submit rule with:
var dialogName = $rootScope.Form.dialogName;
Additionally, you could add your own code at the beginning of other rules to set a flag indicating triggering reason, for example add this at the top of the Click rule of 'Save and Close':
data.$triggeredBy = 'save'
...and add this to the top of a Page Change rule:
data.$triggeredBy = 'backgroundsave';
(Prefixing the variable name with '$' ensures it will not be sent in the form XML data)
If you don't want the trigger the save on page change behavior, you can turn it off in Form Options/Policies:
The problem here is that the Form's "Pre Submit" rule is triggered on any save event as well.
Is there any way to distinguish what type of action triggered the Pre Submit rule in the same script ? I'd expect the context to have this form of detail.
The issue being identified that form "Pre-submit" rule or "Form Submission Preprocessor" service executes on continue of every page, when the form is enabled for "Background Save on Page Change"