Callback validations

Inside the iparams.js file, we can define the event callback methods that are associated with the iparam fields. The logic inside the method gets executed when a particular event is triggered. In our case, we listen to the change event. Whenever the field value is modified, the callback will be fired. Validations and field manipulations can be done by returning appropriate promises and making use of utility methods.

Let us update the domain_name iparam to handle a domainChange callback whenever the value is changed.

config/iparams.json file
{
  "domain_name": {
      "display_name": "Freshdesk Domain Name",
      "description": "Please enter your domain name",
      "type": "text",
      "required": true,
      "events": [{
        "change": "domainChange"
      }]
   }
}

Similarly, let us update validate iparam to handle a validateChange callback whenever the value is changed.

config/iparams.json file
{
  "validate": {
      "display_name": "Validate account credentials",
      "description": "Check this option if the account credentials entered has to be validated",
      "type": "checkbox",
      "events": [{
        "change": "validateChange"
      }]
    }
}

You can now run the app locally with fdk run and test the dynamic installation parameter in action http://localhost:10001/custom_configs.