Email notification empty values

rlehmann
Kilo Sage

Looking for some assistance on an issue with blank emails.

Created 2 new tables as extensions of the Task table and they are CCR (a specific type of request) and CCT (any tasks associated with that request).

The requirement is to send an email notification to the CCR requester, 3 days after a specific CCT task state changes to Pending.

A client script has been configured to set a reminder date field on that CCT, whenever the state changes to Pending.

Created a scheduled job to run periodically (for testing purposes currently set to every 10 min) and when the conditions within the script are met, it triggers an event and sets a reminder sent flag on the CCT.

The event runs on the CCR table and is being used to send an email notification to the requester.

The notification is running against the CCR table and is correctly sent to the requester when the conditions are correct, using an email template.

This template is also using the CCR table.

The issue experienced is that information is missing from the email message being sent.
The number and opened_at fields are empty within the email message sent.

The URI_REF ends up pointing to the scheduled job and not the actual CCR.

find_real_file.png                     find_real_file.png

Also tried leaving the email template empty and have it call an email script, but the number and opened_at are also blank within the email sent.

find_real_file.png

We are on Fuji Patch 13 Hotfix 1.

Any ideas on what the issue may be and the best approach to achieving the requirements, are greatly appreciated?

As always, any assistance is greatly appreciated.

Cheers,

Ron

15 REPLIES 15

Ok ... the number is coming as undefined and the user.name is coming as blank.... Could you please check the element names of whichever field you are doing the query from of these two fields. Could you please tell me the name of the table in which your notification is set up ?



Could you please paste the script you are using for this ?


Email Script:



var grReq = new GlideRecord("u_ccr");


grReq.addQuery("sys_id", current.parent);


grReq.query();


while(grReq.next()) {


      var number = grReq.number;


      var user = grReq.u_requested_for;


      var shortD = grReq.short_description;


      var openAt = grReq.opened_at;


      var sys = grReq.sys_id;


}


  email.setSubject("Request: "+number+" for "+user.name+" requires your approval");


  template.print("Number: " + number + '<br>');


  template.print("Opened: " + openAt + '<br>');



Despite using the word "Approval", we're not actually leveraging approvals against these records.


The tables being used are u_ccr and u_cct, both extended from task.


As mentioned, there are multiple cct records tied to each ccr record and the notification is only based on one specific cct.


The email notification is configured for u_ccr table.


I've confirmed the field names from the table are correct.



My thought were that they are returning as undefined and blank are because both the cct and ccr tables need to be queried.


Tried that also via this email script, but didn't work either:



var grcct = new GlideRecord("u_cct");


grcct.addQuery("active", true);


grcct.addQuery("state", -5);


grcct.query();


while (grcct.next()) {


        var parent = cct.parent;


        var grccr = new GlideRecord("u_ccr");


        grccr.addQuery("active", true);


        grccr.addQuery("sys_id", parent);


        grccr.query();


        while (grccr.next()) {


                  var number = grccr.number.getDisplayValue();


                  var opened = grccr.opened_at.getDisplayValue();


                  template.print('<p>' + gs.getMessage('Number') + ': ${number}<br/>');


                  template.print('<p>' + gs.getMessage('Opened') + ': ${opened}</p>');


        }


}


Sunny Joel
Giga Expert

Hello, I've run into this problem with the exact same scenario.

1. Scheduled job generating the event

2. Notification based on the event

Email displays empty values and points to the scheduled script. Were you able to find a solution for this issue ?

Thanks much.

Can you share the scheduled job? It sounds like you may not be passing the right information to the event. Also an example of the body of the email message to ensure you are using it properly on both ends.

I've passed info either through the GlideRecord (second arg to gs.eventQueue) or a complex JSON object (string) via one of the event parameters.

Sunny Joel
Giga Expert

I need to use one of the parameters for recipient list. Parm1 has information about the user who should receive this email.

Thanks for checking Chuck.