- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-16-2019 12:51 AM
Good day everyone,
Can anyone explain me the meaning of parent.sys_id and sys_id which we write as the second parameter in the addQuery(). and when do we use this ?
Thanks
Kevin
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-16-2019 05:53 AM
Hi There,
for e.g: Scenario like
Look on incident and incident task table
Find how many tasks are present to particular incident
then you should write BR on incident table like
see bellow code
gr.addQuery();
first param:incident is a field on incident task table which contain the sys_id of incident
second param: current.sys_id is sys_id of current incident SO here we should compare with this method,
In this case you should use the current.sys_id.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr=new GlideRecord('incident_task');
gr.addQuery('incident',current.sys_id);
gr.query();
while(gr.next())
{
gs.addInfoMessage(gr.number);//give task number
}
})(current, previous);
Now Again
Take Look on problem table and find out any change is related to same problem then,
Write BR script like,
see
first param: sys_id (current prob sys_id)
second param: current.parent(reference of change) it is also giving the sys_id(becouse it is refernce field)
if the change sys_id is present into problem table then it will give result
(function executeRule(current, previous /*null when async*/) {
var gr=new GlideRecord('change_request');
gr.addQuery('sys_id',current.parent);//both will give you sys_id if same then it will excecute
gr.query();
while(gr.next())
{
gs.addInfoMessage(gr.number);//will get change number if present
}
})(current, previous);
let me know if any doubt
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-16-2019 10:51 PM
Hi,
Can you provide some more scenarios ?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-16-2019 11:06 PM
Hi,
sure, i will update hare.
thanks