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.

GlideRecord - Query by parent

tbalestreri3
Mega Contributor

I have just started using GlideRecords in the last week or so and am loving the. A question I have is how to query project tasks based on parent. This is what I am attempting but it is not working... This is just an example however I will be doing updates using the scripts background module.


var gr = new GlideRecord('pm_project_task');
gr.addQuery('parent', 'PRJ0010604');
gr.query();
while (gr.next()) {
gr.assigned_to == "Tony Balestreri"
gr.update();
}
3 REPLIES 3

tbalestreri3
Mega Contributor

And I did have the ";" after the "tony balestreri"...


CapaJC
ServiceNow Employee
ServiceNow Employee

The value of parent will be the sys_id of the referenced record, not its task number. You could do the following:



gr.addQuery('parent.number', 'PRJ0010604');


And assigned_to needs a sys_id, not the user's name, but you can do the following:


gr.assigned_to.setDisplayValue("Tony Balestreri");


tbalestreri3
Mega Contributor

Perfect, thanks!