I want to add RITM details to Survey Notification on the sc_request table

Steve Briscoe
Tera Contributor

I have created an assessment/survey based on the sc_request table and want to include a list of the RITM's from the request on the survey notification, i.e.

 

Please provide some feedback by completing a survey for your recent request REQ00012345

 

Requested Items:

RITM0000001 - Laptop

RITM0000002 - Keyboard

RITM0000003 - Mouse

Etc

 

I've tried the OOTB mail scripts relating to surveys and requests but none yet done the trick. Any help appreciated.

6 REPLIES 6

Community Alums
Not applicable

Hi @Steve Briscoe ,

Write this email notification on "sc_req_item" table. By doing that you can get both Request Number and Requested Item Number in subject, then your subject will be like this:

Your ${request.number} / ${number} has been registered

Shane J
Tera Guru

Will start off by saying I've never had to deal with a mail script specific to an Assessment but the very basic query is going to be something like:

 

var ritms = new GlideRecord('sc_req_item');
ritms.addQuery('request', current.sys_id); //assumes this is running for the REQ itself
ritms.query();
while (ritms.next()){
template.print(ritms.number + ' - ' + ritms.short_description\n); // \n for carriage return
}

 

Without an example of what you tried to modify OOTB it's hard to say which avenue to further pursue.

Thanks, it's pretty much what you get out of the box...

template.print("<p></p>Requested items:<br />");

    var gr = new GlideRecord("sc_req_item");
    gr.addQuery("request", current.sys_id);
    gr.query();
    
    while(gr.next()) {
    template.print(gr.number + " - " + gr.short_description + "<br />");
        }

 

I'm not sure if the issue is that the current.sys_id is referring to the assessment sys_id rather than the request.

You could check a couple things.  If this is a regular Notification, it should have a Table set on it.  Whatever Table that is, is where it's going to pull that sys_id from.

 

Otherwise you can always throw in a gs.info('Sys_id is ' + current.sys_id) at the beginning of the script, and pull that from the log after you manually trigger one.  Then see where that sys_id exists.

If it is the assessment table, then you just need to use current.ReferenceFieldName that relates it back to the REQ instead of current.sys_id.