How to add Group Members in CC, There are 2 groups in IRQ Challenge (sn_vdr_risk_asmt_challenge_data) table.How to add these 2 group selected in CC (asmt_metric_result table notification)?

sruthig
Tera Expert

How to add Group Members in CC, There are 2 groups in IRQ Challenge (sn_vdr_risk_asmt_challenge_data) table. How to add these 2 group selected in CC (asmt_metric_result table notification)?

I have created below Email Script and added this email script in notification(Notification created in asmt_metric_result table)

var group_list = [];
    var num =current.instance.vdr_tiering_assessment.number;
    var gr = new glideRecord('sn_vdr_risk_asmt_challenge_data');
    gr.addQuery(u_irq,num);
    gr.query();
    if(gr.next()){
        
    group_list.push(current.u_pr_group);
    group_list.push(current.u_com_group);
    }
    var groupMem = new GlideRecord('sys_user_grmember');
    groupMem.addEncodedQuery('group.sys_idIN' + group_list);
    groupMem.query();
    while (groupMem.next()) {
        usermail = groupMem.user.email.toString();
        userName = groupMem.user.name.toString();
        email.addAddress("cc", usermail, userName);
    }

 

NOTE - Flow --> Once the requestor submit a request RITM will create--> After Approve RITM Engagement record (sn_vdr_risk_asmt_vendor_engagement) will create--> Inherent risk questionnaires (sn_vdr_risk_asmt_vdr_tiering_assessment) will create. Assessment will submit to requestor--> After complete assessment IRQ Challenge (sn_vdr_risk_asmt_challenge_data) will create. Inherent risk rating will be calculated in engagement record. 

Note -  IRQ Challenge Record ((sn_vdr_risk_asmt_challenge_data) contains ENGAGEMENT NUMBER, TIERING Assessment number (sn_vdr_risk_asmt_vdr_tiering_assessment) and RITM number etc.

But not working. Can anyone please suggest?

1 ACCEPTED SOLUTION

You can use below syntax to add number in email body.

template.print("your text here"); 

Something like below if you had to include in your script:

var num =current.instance.vdr_tiering_assessment.number;
    var gr = new glideRecord('sn_vdr_risk_asmt_challenge_data');
    gr.addQuery("u_irq",num); // add double qoutes for u_irq variable e.g. gr.addQuery("u_irq",num);
    gr.query();
    if(gr.next()){
     template.print(gr.number); //change backend value of number variable if it different for your table
    group_list.push(gr.u_pr_group); // here shouldn't it be "gr.u_pr_group" not "current.u_pr_group" ?
    group_list.push(gr.u_com_group); // here it should be "gr.u_com_group" not "current.u_com_group" ?
    }

Please mark this as Correct or Helpful if it helps.

Regards,
Abhijit
Community Rising Star 2022

By marking my response as correct or helpful, you contribute to helping future readers with similar issues.
Regards,
Abhijit
ServiceNow MVP

View solution in original post

7 REPLIES 7

Mohith Devatte
Tera Sage
Tera Sage

hello 

try this 

var group_list = [];
var username=[];
var useremail=[];
    var num =current.instance.vdr_tiering_assessment.number;
    var gr = new glideRecord('sn_vdr_risk_asmt_challenge_data');
    gr.addQuery(u_irq,num);
    gr.query();
    if(gr.next()){
        
    group_list.push(gr.u_pr_group);
    group_list.push(gr.u_com_group);
    }
    var groupMem = new GlideRecord('sys_user_grmember');
    groupMem.addEncodedQuery('group.sys_idIN' + group_list);
    groupMem.query();
    while (groupMem.next()) {
        useremail.push(groupMem.user.email.toString());
        username.push(groupMem.user.name.toString());
    }
    email.addAddress("cc", useremail, username);

Hope this helps 

please mark my answer correct if this helps you

Hi Mohith,

I tried the above modified script. Not working

Regards,

Sruthi

Abhijit4
Mega Sage

Your first glideRecord query part looks wrong

var group_list = [];
    var num =current.instance.vdr_tiering_assessment.number;
    var gr = new glideRecord('sn_vdr_risk_asmt_challenge_data');
    gr.addQuery(u_irq,num); // add double qoutes for u_irq variable e.g. gr.addQuery("u_irq",num);
    gr.query();
    if(gr.next()){
        
    group_list.push(current.u_pr_group); // here shouldn't it be "gr.u_pr_group" not "current.u_pr_group" ?
    group_list.push(current.u_com_group); // here it should be "gr.u_com_group" not "current.u_com_group" ?
    }

Also in second part of gliderecord, one line needs to changed I guess :

groupMem.addEncodedQuery('groupIN' + group_list.join(","));

Update mentioned changes and verify if it working.

Let me know if you have any further queries.

Please mark this as Correct or Helpful if it helps.

Regards,
Abhijit
Community Rising Star 2022

By marking my response as correct or helpful, you contribute to helping future readers with similar issues.
Regards,
Abhijit
ServiceNow MVP

Hi Abhijith,

I tried the above modified script. Not working

Regards,

Sruthi