parent.sys_id and sys_id, etc.

Kevin Smith2
Giga Expert

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

1 ACCEPTED SOLUTION

Varsha21
Giga Guru

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

 

View solution in original post

6 REPLIES 6

Hi,

Can you provide some more scenarios ?

Thanks

Hi,

sure, i will update hare.

 

thanks