- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2019 07:03 AM
I'm currently creating a mail script to query a Task's related records and display those related record's fields in a determined format.
Querying the records I need is no problem, however, how would I go about getting each related record object and parsing the fields to string values to display in a mail script?
I've used the JSON.parse() method before in record producer's however that was for a variable and not a record object.
I'll provide a screenshot for reference.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2019 09:51 PM
Hi Thomas,
so you can print them in email using
template.print(gr.source_ip);
what issue you are facing?
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2019 07:19 AM
Hi Thomas,
are you saying that you want to print the field label and field value in the email body like
Incident INC0001
Assignment Group Service Desk
Do you want to print for all fields or for few?
sample script below:
var siarraTSK = current.sys_id;
var gr = new GlideRecord('tableName'); // use your table name here
gr.addQuery('siarra_task', siarraTSK);
gr.query();
if(gr.next()){
var recFields = gr.getFields();
for (i=0;i<recFields.size();i++)
{
var glideElement = recFields.get(i);
template.print('Field is ' + glideElement.getName() + ' Value is: ' + glideElement);
}
}
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2019 10:06 AM
Hi Ankur,
My goal is to print all 6 specified field string values on each related record. The fields I would like print on each related record are:
user
source_ip
destination_ip
ports
service
protocol
direction
^
all of the above fields are string fields except for direction which is choice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2019 09:51 PM
Hi Thomas,
so you can print them in email using
template.print(gr.source_ip);
what issue you are facing?
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-02-2019 10:16 AM
I had overthought the process, just the gr.fieldname worked.
Thank you!
