Need to add dynamic link in notification

Ashwini8
Tera Contributor

Hi All,

I have created a notification on user table so when a new user is created it should trigger notification to a department head to add few more details and i have provided the link in the notification that link will redirect to service portal and opens a catalog item. But i want to add it dynamically when we move the code to different intance also it should work.

Notification detalis

When to send : Record Inserted

Who will recieve : department head

What it will contain: http://details.about.thelink. It will resirect to portal.

Please suggest how can i achieve this.

1 ACCEPTED SOLUTION

Jaspal Singh
Mega Patron
Mega Patron

Hi Tejaswini,

 

You can simply pass it as below.

Where sp is my portal name & sys_id is sys_id of item which ideally will be same across instances thus making it dynamic

find_real_file.png

 

View solution in original post

7 REPLIES 7

Jaspal Singh
Mega Patron
Mega Patron

Hi Tejaswini,

 

You can simply pass it as below.

Where sp is my portal name & sys_id is sys_id of item which ideally will be same across instances thus making it dynamic

find_real_file.png

 

Hi Jaspal.

In mail script what i need to write?

Hi Tejaswini,

 

If you use above there is no need to pass or use any mail script as if you closely look we are not pasing the instance name as hard-coded values.

If you will to go with mail script approach you can use below in your mail script.

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {

	template.print('<a href="https://' + gs.getProperty('instance_name') + '.service-now.com/sp?id=sc_cat_item&sys_id=039c516237b1300054b6a3549dbe5dfc" target="_blank">' + Click Here + '</a>');


})(current, template, email, email_action, event);

 

Call the mail script in notifiation body in format.

${mail_script:yourmailscriptname}

Replace yourmailscriptname with correct name of mail script you created with above code.

Note: Assuming the sys_id of item where you want to direct post link click is same across instances. You need to replace that as well in code above.

 

Does this work even if the user clicks a link in a 3rd party email client?