- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2023 06:43 AM
Hey all!
I am running into an issue trying to create a related list on the cmdb_ci table that references change_request. I have the relationship created but can't get a script to work that successfully queries task_ci. The requirements are - Related list on cmdb_ci to show change requests where the current CI Record is an affected ci on a change.
I have been able to get it to work by directly going to task_ci but they need the fields from Change showing not the fields from task_ci.
My current code looks like -
(function refineQuery(current, parent) {
current.addQuery('RLQUERYtask_ci.ci_item', parent.sys_id);
})(current, parent);
This returns all change records, not filtered in any way. Any suggestions or input is greatly appreciated!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2023 07:35 AM
This works if anyone comes across the same question later -
(function refineQuery(current, parent) {
var chgs = [];
var gr = new GlideRecord("task_ci");
gr.addQuery("ci_item", parent.sys_id);
gr.addEncodedQuery('taskSTARTSWITHchg');
gr.query();
while(gr.next())
chgs.push(gr.getValue("task"));
current.addQuery('sys_id', 'IN', chgs.join());
})(current, parent);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2023 07:00 AM
I have also tried doing a GlideRecord and join with the same results -
(function refineQuery(current, parent) {
var chgs = [];
var gr = new GlideRecord("task_ci");
gr.addQuery("ci_item", current.sys_id);
gr.addEncodedQuery(taskSTARTSWITHchg);
gr.query();
var count = 0;
while(gr.next())
chgs.push(gr.getValue("change_request"));
current.addQuery('sys_id', 'IN', chgs.join());
})(current, parent);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2023 07:35 AM
This works if anyone comes across the same question later -
(function refineQuery(current, parent) {
var chgs = [];
var gr = new GlideRecord("task_ci");
gr.addQuery("ci_item", parent.sys_id);
gr.addEncodedQuery('taskSTARTSWITHchg');
gr.query();
while(gr.next())
chgs.push(gr.getValue("task"));
current.addQuery('sys_id', 'IN', chgs.join());
})(current, parent);