How to populate Request For name in Email notification

shaik_irfan
Tera Guru

Hello Everyone,

i want to populate Requested By name under Email template, Requested For (u_req_for) is from RITM table which should be populated on Template i tried Select Variables which is present in the Template but i unable to find the Requested For name since the email template is written on Approval table.

Can anyone please help me out how to populate the RITM table field on Approval table ?

1 ACCEPTED SOLUTION

Rajesh feedbacks were helpful but you will still need to query the req_item table;



Please try this just for the fun somewhere on your code



<mail_script>


var ritm = new GlideRecord('sc_req_item');


if(ritm.get(current.sysapproval)){


var req_for = ritm.u_req_for.name;


template.print("Requested for :"+ritm.request.requested_for.name);


template.print("Requested by :"+ritm.u_req_for.name);


}


</mail_script>


View solution in original post

27 REPLIES 27

younes_sebti
Kilo Sage

You have to configure a mail script to query the requested item table. Not much of a choise


Then use the template.print function to print it



<mail_script>


var ritm = new GlideRecord('sc_req_item');


if(ritm.get(current.sysapproval)){


var req_for = ritm.u_req_for.name;


template.print("Requested for :"+req_for);


}


</mail_script>



Of course you don't need this trick for fields that are on the task table.


These can be accessed directly like for example the opened by ${sysapproval.opened_by}





I didn't test this code but I'm 100% certain that it will work


Younes,



there is already a mail script running for this template but i am not very sure where to add as i am new to scripting i an totally blank


Rajesh Mushke
Mega Sage
Mega Sage

Hi Irfan,



just add below line in HTML Message :



Request Requested for: ${request.requested_for}




Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke

Yes this will work if Shaik wants to use the sc_request requested for.