How to get Task number in subject line for email notification.

Saridha_L1
Tera Expert

Hi Team,

I have configured an email notification on RITM table,would like to populate Task number in notification subject.There is an existing post , I could not find an answer. So please help me.

 

Regards,

Saridha.L

1 ACCEPTED SOLUTION

Shishir Srivast
Mega Sage

as everybody already informed, you need to use email API setSubject to set the email subject with task number but just wanted to add one thing here is, setSubject will replace the whole email subject so if you want to put Task number along with other other email subject content then you can use the code provided by bhagya1764 by updating the below line of code.

email.setSubject(gr.number + ' : ' + 'YOUR REST OF THE EMAIL SUBJECT TEXT');

View solution in original post

7 REPLIES 7

Anurag Tripathi
Mega Patron
Mega Patron

just add this in the subject

 

${number}

-Anurag

Gaurav Bajaj
Kilo Sage

Hi,

You can achieve it by using email notification script if you have only one task associated with the requested item.

You need to query the sc_task table and fetch the right record based on the RITM and then put in a variable.

Once you have the variable, just use email.setSubject method to populate task number in subject.

find_real_file.png 

https://docs.servicenow.com/bundle/jakarta-servicenow-platform/page/script/server-scripting/concept/c_ScriptingForEmailNotifications.html

 

find_real_file.png

 

Please mark it correct/helpful based on the response.

Thanks
Gaurav

 

Jaspal Singh
Mega Patron
Mega Patron

Hi Saridha,

 

Does the Task number refer to Catalog Task or RITM? If RITM you can use ${number} & it should work well. If  Catalog Task you would require notification mail script.

 

Thanks,

Jaspal Singh

 

Hit Helpful or Correct on the impact of response.

Thank you all.

I have tried mail script, its not working. Since I have configured the notification on RITM, If I user${number}, its populating RITM Number.

 

Regards,

Saridha.L