Email Script Not working

JVINAY
Tera Contributor

Hello,

 I have written below Email script 

----------------------------------

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

    // Add your code here
    if(current.getTableName() == 'u_cloud_intake_task') {
        var url1 = gs.getProperty('glide.servlet.uri') + 'u_cloud_intake_request?sys_id=' + current.getValue('sys_id');
        template.print('<a href="' + url1 + '">' + current.getValue('number') + '</a>');
    } else if(current.getTableName() == 'u_cloud_intake_request') {
        var url2 = gs.getProperty('glide.servlet.uri') + 'u_cloud_intake_request?sys_id=' + current.getValue('sys_id');
        template.print('<a href="' + url2 + '">' + current.getValue('number') + '</a>');
    }
--------------------------
 
I have added this email script in One notification body , 
Out put :

it getting CIT number , I want CIR number,

Please help me .

Thank you

2 ACCEPTED SOLUTIONS

@JVINAY 

earlier you said the notification is on u_cloud_intake_request  table so I gave script accordingly

AnkurBawiskar_0-1754481565153.png

 

If notification is on u_cloud_intake_task and you want to show REQ then simply use this and no email script required

Use the correct field name on the u_cloud_intake_task which refers to the Intake Request

AnkurBawiskar_1-1754481898414.png

 

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

View solution in original post

@JVINAY 

is the field name "u_cloud_intake" on intake task referring to intake request?

share field configuration screenshot

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

View solution in original post

22 REPLIES 22

Chaitanya ILCR
Kilo Patron

Hi @JVINAY ,

try this script

 if (current.getTableName() == 'u_cloud_intake_task') {
     var url1 = gs.getProperty('glide.servlet.uri') + 'u_cloud_intake_task.do?sys_id=' + current.getValue('sys_id');
     template.print('<a href="' + url1 + '">' + current.getValue('number') + '</a>');
 } else if (current.getTableName() == 'u_cloud_intake_request') {
     var url2 = gs.getProperty('glide.servlet.uri') + 'u_cloud_intake_request.do?sys_id=' + current.getValue('sys_id');
     template.print('<a href="' + url2 + '">' + current.getValue('number') + '</a>');
 }

 you can use URI or URI_REF directly in the notification instead of email script 

refer below for the same

https://developer.servicenow.com/dev.do#!/learn/learning-plans/yokohama/new_to_servicenow/app_store_...

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

Hi @Chaitanya ILCR 

I have added URL for this

JVINAY_0-1754477911809.png

but its coming CIT task number,

JVINAY_1-1754477979529.png

 

But I want CIR Number - Central intake request number

Hi @Chaitanya ILCR 

I have updated this code , but this it's coming CIT number  Not CIR Number

 

JVINAY_0-1754478603913.png

 

Brief explanation :

This notification in the Cloud task table : u_cloud_intake_task  

Parent of this Cloud task in Cloud account request

Cloud account request table name  :  u_cloud_intake

But I want to add in the notifications  u_cloud_intake_request (central intake request) in the Email body

 

Thank you