- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2023 06:06 PM
Hi, all.
I would like to use gliderecord to retrieve a value from a related list of a certain record.
How can I achieve these?
I would be glad to know about even the smallest things.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2023 06:20 PM
Hi @RyoyaFukuda ,
Hope you are doing well.
For example - I am in an incident record and want to fetch short description of all the incident_task records in its related list
(function executeRule(current, previous /*null when async*/) {
var getIncTask = new GlideRecord("incident_task");
getIncTask.addQuery("incident",current.sys_id);
getIncTask.query();
while(getIncTask.next()){
gs.addInfoMessage(getIncTask.short_description);
}
})(current, previous);
The code will be more or less similar to that of other requirements as well
Please mark this response as correct or helpful if it assisted you with your question.
Regards,
Harshal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2023 06:20 PM
Hi @RyoyaFukuda ,
Hope you are doing well.
For example - I am in an incident record and want to fetch short description of all the incident_task records in its related list
(function executeRule(current, previous /*null when async*/) {
var getIncTask = new GlideRecord("incident_task");
getIncTask.addQuery("incident",current.sys_id);
getIncTask.query();
while(getIncTask.next()){
gs.addInfoMessage(getIncTask.short_description);
}
})(current, previous);
The code will be more or less similar to that of other requirements as well
Please mark this response as correct or helpful if it assisted you with your question.
Regards,
Harshal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2023 06:31 PM
Hi,
Here's an example:
// show related list (watch_list) values for indicents
var incRec = new GlideRecord('incident');
incRec.addEncodedQuery('watch_listISNOTEMPTY');
incRec.query();
gs.info("Found " + incRec.getRowCount() + " records to process.");
while (incRec.next()) {
gs.info("Incident: " + incRec.number + " watch_list = " + incRec.watch_list + ".");
}
That returns all incident records where watch_list is not empty. Your query will be on what is a "certain record".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2023 08:48 PM
so what did you start with and where are you stuck?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader