Notification - Information from separate table

shane_davis
Tera Expert

I have a notification called "More Information Needed" where I am attempting to email the u_submitted_by person that more information is needed on their Change Request when the approving manager changes the approval state to More Information Required which I added and is working. The notification information is below. My only issue here is that, since the notification is on the sysapproval_approver table with condition "State is More Information Required," I can't get the Change Request information in the body of the email NOR put u_submittted_by as the "who will receive" person. I've put the code below directly in the notification, but it keeps printing the code instead of the Change information.

NOTIFICATION:
Table: sysapproval_approver
Condition: State IS More Information Required
Subject: More information is required on......I would like to put the Change Request number here
Send when record inserted or updated; Inserted and Updated are true
Weight: 0

1 ACCEPTED SOLUTION

Jim Coyne
Kilo Patron

That could be a little tricky because of where the field is in the table hierarchy. Is the u_submitted_by field on the Task or Change Request table? I'm assuming it is not on the Task table, otherwise you would be able to see it when you expand the "Approval for" field in the list:

find_real_file.png

I thought you could use a setting described here to allow the fields from the Change table to also appear -
http://wiki.servicenow.com/index.php?title=Personalizing_Lists#Adding_Extended_Fields_to_Base_Table_Lists. Unfortunately that does not work with that particular field type.

However, there is a trick you can use, by running the following Background Script to force that field in:
Note - be very careful when running Background Scripts as you can really mess things up if you are not careful.



(function(){
var gr = new GlideRecord("sysevent_email_action");
if (gr.get("sys_id of your email notification")) {
gr.recipient_fields = "sysapproval.ref_change_request.u_submitted_by";
gr.update();
}
})();


I tried it in demo022 and it works. The trick is the "ref_" before the "change_request" table name, telling the system the field is not on the Task table (sysapproval is a reference field to Task), but on the Change Request extended table.


View solution in original post

5 REPLIES 5

That's good to hear and you are welcome.