Email script error

Arun_Manoj
Mega Sage

Hi,

 

Created Email script for hyperlink to the compliance case workspace for the record.

it is showing "

Email script render error: email script [ Compliance_case ] does not exist" error

 

 

 

(function runMailScript(current, template, email, email_action, event) {

    // var taskSysId = current.sys_id;

    // var gr = new GlideRecord('sn_grc_case_mgmt_case_task');

    // gr.get(taskSysId);  // simpler way to fetch by sys_id

 

    // if (gr.isValidRecord()) {

    //     var parentSysId = gr.getValue('parent');

    //     var taskNumber = gr.getValue('number');

 

        // Get base URL from system properties

        var baseURL = gs.getProperty('glide.servlet.uri') + gs.getProperty('glide.sys.servlet_path');

 

        // Build workspace path - adjust as necessary for your environment

        var workspacePath = 'now/risk/compliance/record/sn_grc_case_mgmt_case/' + current.parent;

 

        // Full clickable URL to the parent record

        var workspaceURL = baseURL + workspacePath;

 

        // Create an HTML anchor tag with the task number as link text

        var clickableLink = '<a href="' + workspaceURL + '" target="_blank">' + current.parent.number + '</a>';

 

        // Print the clickable link into the email body

        template.print(clickableLink);

 

        template.print('Task record not found.');

   

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

 

3 REPLIES 3

GlideFather
Tera Patron

Hi @Arun_Manoj,

 

is Compliance_case in the same scope?

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


Ankur Bawiskar
Tera Patron
Tera Patron

@Arun_Manoj 

email script is in which scope?

what debugging did you do by adding gs.info() ?

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

Chaitanya ILCR
Mega Patron

Hi @Arun_Manoj ,

 

make sure the name of the email script is correct and you have added the correct name in the notification

 

example

the highlighted email script doesn't exist in my instance

 

ChaitanyaILCR_0-1756805797615.png

 

when I preview the notification it throws the error you have mentioned

ChaitanyaILCR_1-1756805848327.png

 

just check if you have used any additional spaces and remove them if required 

 

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

Regards,
Chaitanya