Skip to content

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

Copy the documentId from this document and replace the documentId in 'Issue Form' template to link the ruleset.

{
#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();
                }
            }
        }
    }
}