Contextual Search results in email

rajasekharteja
Tera Guru

Hello All,

 

I got a requirement where I need to send an email to Requester once the HR case is submitted for any COE.

 

I have created the Notification and calling Email Script as shown in below screen shot.

I could see Contextual search results are showing under the record but it's not showing up in email.

 

Please help me on this , debugging for almost 2 days couldn't able to resolve this one.

rajasekharteja_0-1767792333368.png

 

 

Thanks,

Ram

9 REPLIES 9

@rajasekharteja 

this email script might be bringing the data

share that script here

AnkurBawiskar_0-1767799095756.png

 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar 

 

Note :

 

Email Script : cxs_EmailSearchResults is OOB one and I could see it's same in working and non working Instance.

 

Email Script:

(function() {
    var searchRequest = cxs_App.getActions("cxs_TableActions", current).getEmailSearchRequest(email_action);
    if (!searchRequest || searchRequest == null || !searchRequest.query.freetext || !searchRequest.meta.get("runAsUser"))
        return;

    var imp = new GlideImpersonate();
    var previousUserId = imp.impersonate(searchRequest.meta.get("runAsUser"));
    var searchResponse = SNC.SearchService.search(searchRequest);
    var searchResponseObj = new JSON().decode(searchResponse.toJSON());
   
    template.print(cxs_App.getActions("cxs_FormatResults", searchResponseObj).usingMacro({
        "result_header_macro": "cxs_results_header_email",
        "result_macro": "cxs_result_email"
    }));

    if (previousUserId)
        imp.impersonate(previousUserId);
})()
 

 

Below is the script present in Email Template(which is present in working Instance) :

 

Short Description: ${short_description}
Priority: ${priority}
Description(description): ${description}
State: ${state}

 
 

 
${mail_script:change_request_summary}
 
Comments:
${sysapproval.description}
 

 
${mailto:mailto.approval}
 

 
${mailto:mailto.rejection}
 

 

 
Click here to view Approval Request: ${URI+&sysparm_record_target=sysapproval_approver}
Click here to view ${sysapproval.sys_class_name}: ${sysapproval.URI}


Please let me know something needs to be changed.

@Ram141 & @rajasekharteja 

then include that email script in your email template and see if that works

since you are using email template it won't use email body, so include that email script in your email template

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@rajasekharteja @Ram141 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar 

Thank you so much for providing quick response on this.

Team has decided to put this on hold for now will try and update on this in few days.

Thank you.