Triggering a notification containing requested item variables from flow designer

sarahjantz
Tera Expert

I am trying to trigger an email notification from flow designer that contains all of the variables in a requested item. I was able to get the notification to populate the variables using the following script and using the sc_task table, but the workflow throws an error "Notification requires table sc_task, record is of type sc_req_item". If I change the table to sc_req_item, it does not pull the variables into the notification. Can somebody help?

 

DS notification.PNG

 
 
 
 
 
ds workflow notification.PNG
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {



    var set = new GlideappVariablePoolQuestionSet();
    set.setRequestID(current.request_item.sys_id); //changed
    set.load();
    var vs = set.getFlatQuestions();
    for (var i = 0; i < vs.size(); i++) {
        if (vs.get(i).getDisplayValue() != '' && +vs.get(i).getLabel() != '') {
            template.space("\n");
            template.print("\n" + vs.get(i).getLabel() + "::" + vs.get(i).getDisplayValue() + "\n");
        }
    }
})(current, template, email, email_action, event);
1 ACCEPTED SOLUTION

@sarahjantz : This will work, please use the below script and make sure the notification is configured on [sc_req_item] table.

 

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {



    var set = new GlideappVariablePoolQuestionSet();
    set.setRequestID(current.sys_id); //changed
    set.load();
    var vs = set.getFlatQuestions();
    for (var i = 0; i < vs.size(); i++) {
        if (vs.get(i).getDisplayValue() != '' && +vs.get(i).getLabel() != '') {
            template.space("\n");
            template.print("\n" + vs.get(i).getLabel() + "::" + vs.get(i).getDisplayValue() + "\n");
        }
    }
})(current, template, email, email_action, event);

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

View solution in original post

7 REPLIES 7

Sainath N
Mega Sage

@sarahjantz : Looking into your screenshots, notification was configured on "sc_task" table and the the input record you are supplying in the flow to notification is an RITM. Please change the trigger record to the task instead of RITM.

 

sainathnekkanti_0-1703873285454.png

 

Note : Both the table in the notification and the record you are supplying as input should be of same class. Based on your requirement on the notification (to be sent on RITM or catalog task) change the table in the notification or supply the right record in the flow as described 

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

It does not give me an option to change to a catalog task record. Additionally, if I change the table on the notification to sc_task, it does not allow me to select the notification in the Notification field because the table field (which is read only) is set to sc_req_item.

@sarahjantz : Assuming that a task is being created in the flow, please refer to the below screenshot.

 

sainathnekkanti_0-1703874465508.png

 

sainathnekkanti_1-1703874485303.png

 

The notification list is based on the table; it shows only the notifications from the selected table. In the above case, notification should be configured on the sc_task table.

 

Option 2: If you want to send at RITM level, notification should be configured on sc_req_item table.

 

sainathnekkanti_2-1703874578835.png

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

I do believe it should be a RITM notification because the notification isn't related to a task, it is related to the RITM and the RITM variables, but utilizing the sc_requested_item table doesn't populate the variables of the RITM the way that I need it to. I need to create a notification to a group of users that tells them what is being requested.