Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

CI Relationship related list for all rels

cyked
Mega Guru

I want to create a related list for CI form that shows all rels where current CI is the parent or child on cmdb_rel_ci, is this possible?

 

https://docs.servicenow.com/bundle/madrid-platform-user-interface/page/administer/form-administratio...

 

I've tried creating a relationship with refinequery and it works if it's simply "current.addQuery('parent', parent.sys_id);" but If I do child it just returns EVERY record on cmdb_rel_ci.  

(function refineQuery(current, parent{

	// Add your code here, such as current.addQuery(field, value);
	current.addQuery('parent', parent.sys_id);
	

})(current, parent);

 

 

i've tried a few variations poking around community/dev pages without success.

 

var qc = current.addQuery('parent', parent.sys_id);
qc.addOrCondition('child', child.sys_id);

 

var qc = current.addQuery('parent', parent.sys_id).addOrCondition('child', child.sys_id);;

1 ACCEPTED SOLUTION

Oops...Correction

 

var qc = current.addQuery('parent', parent.sys_id);
qc.addOrCondition('child',parent.sys_id);


Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

4 REPLIES 4

SanjivMeher
Mega Patron
Mega Patron

I think you need to do below. There is no child object. You need to use current

 

var qc = current.addQuery('parent', parent.sys_id).addOrCondition('child', current.sys_id);;


Please mark this response as correct or helpful if it assisted you with your question.

not working, only gives me the downstream dependency CIs.  same thing if I do it this way.

 

var qc = current.addQuery('parent', parent.sys_id);
qc.addOrCondition('child', current.sys_id);

Oops...Correction

 

var qc = current.addQuery('parent', parent.sys_id);
qc.addOrCondition('child',parent.sys_id);


Please mark this response as correct or helpful if it assisted you with your question.

Yes!  Thank you, you're awesome.