Automate A Template
This video gives a quick demonstration of rulesets.
By no means is this example exhaustive. There is MUCH more functionality available, but it shows the basic process of creating, linking and testing a ruleset.
Before diving in deeper we recommend that you read the documentation on ruleset development.
A different template is required for creating rulesets. Copy the following link and alter the URL for your specific environment:
https://your-environment.formbird.com/form/224bc62858d73ce57a9cb85e
Once you have created and saved your ruleset document, navigate to the 'Issue' template you created earlier and append the following to the template URL - /abb10be0-b9dc-11e7-8013-1f0b88022708
eg: https://app-dev.formbird.com/form/f2038280-fc11-11e8-ac93-9d9450e01089/abb10be0-b9dc-11e7-8013-1f0b88022708
This provides the method to link the ruleset to the template. In the 'OnFieldChange (Client) related field, search for the name of your ruleset and save.
{
#include "JayRule Ruleset Overlay JS",
ruleset : {
name : 'myApplication - Issue - OnFieldChange',
ruleSetDates : {
ruleCondition : function(ntf) {
var fieldChanged = ntf.context.fieldChanged;
return (fieldChanged === 'status');
},
ruleAction : function(ntf) {
if(ntf.document.status === 'Started'){
ntf.document.startedDate = new Date();
}
if(ntf.document.status === 'Completed'){
ntf.document.completedDate = new Date();
}
}
}
}
}