Create a link for Approve/Reject

Prasnajeet1
Giga Guru

Hi All

I am creating a link to approve/reject a request. In my email script I have written below script. When user click on the link it should redirect the user to sysapproval_approver table to that record.

 

template.print('<a href='+gs.getProperty('glide.servlet.uri')+'sysapproval_approver.do?sys_id='
+ current.sys_id + '>' + "Click here to Approve/Reject "+ current.sysapproval.number + '</a>');
 
Ideally the link appeared like: "Click here to Approve/Reject" but this coming like "Click here to Approve/Reject undefined".
Can someone please help to correct the link and helps to achieve the requirement.
 
1 ACCEPTED SOLUTION

Prasnajeet1
Giga Guru

Hi All

Thank you for all your answer. Really appreciated. Finally I am able to fix the issue. Below is the script.

 

template.print('<a href='+gs.getProperty('glide.servlet.uri')+'sysapproval_approver.do?sys_id='
+ current.sys_id + '>' + "Click here to Approve/Reject "+ current.number + '</a>');

View solution in original post

18 REPLIES 18

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Prasnajeet1 

 

Have a look in OOTB notification

https://INSTANCENMAE.service-now.com/now/nav/ui/classic/params/target/sysevent_email_action.do%3Fsys_id%3D927afd45c0a8010a001f28267acf98e4%26sysparm_record_list%3Dactive%253dtrue%255enameCONTAINSappro%255eORDERBYorder%26sysparm_record_row%3D2%26sysparm_record_rows%3D40%26sysparm_record_target%3Dsysevent_email_action%26sysparm_view%3Dadvanced%26sysparm_view_forced%3Dtrue

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Hi Atul

Thanks for your quick response however OOB is not something I am looking. In case of oob it is coming as "LINK" however in my case I am looking the entire line as link along with the RITM number.

Something like "Click here to Approve/Reject RITM000000"

 

Servicenow34
Tera Guru

Hello @Prasnajeet1,

 

Kindly use below code in your email script.

var url=gs.getProperty('glide.servlet.uri')+'sysapproval_approver.do?sys_id='+ current.sys_id;
template.print("Click here to Approve/Reject:" );
template.print('<a href=' + url + '>'+current.sysapproval.number+'</a>' );

This will give below output.

Servicenow34_0-1707719257606.png

which will redirects you to the approval page.

Servicenow34_1-1707719339228.png

 

Hope this help!

Kindly mark helpful/accepted if assists.

Thank you!

Hi

 

I tired with your script as well but not sure what is wrong in my instance I am  still getting the link as "Click here to Approve/Reject undefined". 

Could you please help me on this