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

Ankur Bawiskar
Tera Patron
Tera Patron

@JVINAY 

the record for which you are testing is belonging to which table Intake Task or Intake Request?

based on that it will show the number.

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

Hi @Ankur Bawiskar ,

Below Code is working for " u_cloud_intake_request "table notifications

JVINAY_0-1754474528399.png

But not Working on "u_cloud_intake_task" table.

Please help me to modify this code

Thank you .

@JVINAY 

seems you are trying to re-use the email script in both the notifications.

it should work.

Did you add logs and see what came in the current.getTableName() when the email script runs for Intake Task 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

@Ankur Bawiskar ,

Not working showing Empty in the CIR number

 

I have created new Email script :

JVINAY_0-1754475549197.png

Please suggest modifications ,

My requirement is add CIR Plat form link in email notification, we have already in Portal link

 

Thank you