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

Hi Abhijith,

I made below changes .

 

gr.addQuery("u_irq",num);

group_list.push(gr.u_pr_group); 
group_list.push(gr.u_com_group); 

Now Working as expected.

Can you please let me know how to add IRQ Challenge(sn_vdr_risk_asmt_challenge_data) number in notification? Now I can add 2 groups field in IRQ Challenge record as Email Recipient (cc). How to add this IRQ Challenge (sn_vdr_risk_asmt_challenge_data) number in Email body?

Please suggest

Regards,

Sruthi

 

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

Hi Abhijit,

Thanks Abhijith. Worked now. 

Can you please help me with the below question which I posted related to this.

https://community.servicenow.com/community?id=community_question&sys_id=81e1a8efdb659118dd886c8e13961908

Regards,

Sruthi