How to build URL

vidhya_mouli
Giga Sage

I am trying to build this URL in a email script.

 

https://myinstance.com/now/sow/record/sc_req_item/b55508be974ebd10680c3bafe153af6c/params/extra-params/subTabIndex%2F1/selected-tab-index/1/sub/record/sysapproval_approver/c65548be974ebd10680c3bafe153af12

 

This is for approval. Can someone help me with this?

1 ACCEPTED SOLUTION

vidhya_mouli
Giga Sage

Managed to build the URL and it is as follows.

var approvalRecUrl = '/' +'now/sow/record/sc_req_item/' + current.sysapproval.sys_id + '/params/extra-params/subTabIndex%2F1/selected-tab-index/1/sub/record/sysapproval_approver/' + current.sys_id;
 

View solution in original post

5 REPLIES 5

Aniket Bhanse
Tera Guru

@vidhya_mouli 

You can generate a vairable URL by making the sys_ids variable, please check below:

Considering this is your actual link: https://myinstance.com/now/sow/record/sc_req_item/b55508be974ebd10680c3bafe153af6c/params/extra-params/subTabIndex%2F1/selected-tab-index/1/sub/record/sysapproval_approver/c65548be974ebd10680c3bafe153af12

 

Take "b55508be974ebd10680c3bafe153af6c" into a variable. Call this using GlideRecord Query

Take "c65548be974ebd10680c3bafe153af12" also into a variable and call it using GlideRecord Query. 

Your script will look similar to this:

// Capturing the first sysid into a variable
var gr = new GlideRecord("your table name");
	gr.addQuery("name", "value");
	gr.query();
	if (gr.next()) {
	   var sysID1 = gr.sys_id;
	}

// Capturing the second sysid into a variable
var gr2 = new GlideRecord("your table name");
	gr2.addQuery("name", "value");
	gr2.query();
	if (gr2.next()) {
	   var sysID2 = gr2.sys_id;
	}


var actualUrl = gs.getProperty('glide.servlet.uri') + "now/sow/record/sc_req_item/" + sysID1 + "/params/extra-params/subTabIndex%2F1/selected-tab-index/1/sub/record/sysapproval_approver/" + sysID2;

template.print(actualUrl);

 

Mark it correct or helpful if it helps you.

@vidhya_mouli if your issue is resolved, please mark an answer Correct. This way the thread will be closed and it will help other users too. 


Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!

Geetanjali Khya
Tera Contributor

Hello there,

You can try below snippet:

var instance = "dev@service-now.com";
<a href="https://' + instance + '/now/sow/record/sc_req_item/b55508be974ebd10680c3bafe153af6c/params/extra-params/subTabIndex%2F1/selected-tab-index/1/sub/record/sysapproval_approver/c65548be974ebd10680c3bafe153af12">Link_Name</a>

Instead RITM sys_id and Approval sys_id, user current.field and it will work.

Thanks.
Geetanjali K

 

 

Ankur Bawiskar
Tera Patron
Tera Patron

@vidhya_mouli 

should be simple

email is on which table? I assume it's sysapproval_approver then no need of email script

directly add in email body since the only thing dynamic is the sysId of the record

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader