Survey should be trigger after x days of incident closure.

servicenow_devo
Tera Expert

Hi All,

Can anyone help me out to figure a solution for sending survey to users after x days of incident closure.

Currents survey is sent at the state changes to closed instead or this survey should be send after x days of being state changed. If there any way and how it can be achieved. Is it achieved by making changed is auto assessment BR ?

 

 

Regards

Thankyou
1 REPLY 1

Laszlo Balla
ServiceNow Employee
ServiceNow Employee

You can check the Trigger Condition record (asmt_condition) and find the one that fits your description and runs on the incident table. You can see the business rule that triggers the creation of the respective assessments, e.g.:

LaszloBalla_0-1684165462669.png

 

You will see that unfortunately, you are not allowed to edit the 'Business Rule' field on the trigger condition record.

That means you will either have to edit that business rule (you also cannot see or edit the Script Include that the business rule is calling), or somehow work around it. However, the business rule can only run of there is an action on the table, and it is unlikely that there would be any action on an incident after it's closed - meaning you will not have any action to trigger the BR.

 

What I would try first is something along these lines:

  1. Deactivate the OOTB BR
  2. Create a scheduled job (sysauto_script) to run daily at the time of your choosing.
  3. Set the script to something like this:
    var triggerCondition = '249e70b0875013005d90bba826cb0bbf'; // this must be the Sys ID of the survey triggr condition record
    
    function closed10() {
        var inc10 = new GlideRecord('incident');
    	inc10.addEncodedQuery('closed_atRELATIVEGT@dayofweek@ago@11^closed_atRELATIVELT@dayofweek@ago@10');
        inc10.query();
        while (inc10.next()) {
            (new sn_assessment_core.AssessmentCreation()).conditionTrigger(inc10, triggerCondition);
        }
    }
    
    closed10();​

 

Feel free to add anything else to the script, including logging. If you prefer, you an also build this logic in Flow Designer, with a daily trigger schedule and a custom action with a script block (that could take the trigger condition record as an input to make it reusable).