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.

addQuery in Relationship

Miguel1
Tera Contributor

Hi experts, I made a relationship using addQuery as below

(function refineQuery(current, parent) {

// Add your code here, such as current.addQuery(field, value);
current.addQuery("time_card", current.task.number);
current.addQuery('state', 'IN', 'approved,processed');

})(current, parent);

this query show only approved and processed time cards but shows all the time cards from all the projects, so, I would like that show only the time cards from a project with the same EG Project ID.
I would like to know how can I do this?

Does anyone have any ideas?
thanks so much!!

find_real_file.png

4 REPLIES 4

Pranav Bhagat
Kilo Sage

You can add a query for same project

 

current.addQuery(‘projectid', ‘number');

Hi Pranav! thanks for answering!

Doesn't work the ID is in both tables but I still can't relate them  

Any other suggestions?

Mike Patel
Tera Sage
Change current.addQuery("time_card", current.task.number); To current.addQuery("time_card", current.task.sys_id);

Hi Mike! Thanks for answering!

Doesn't work... 
by the way the ID are in both tables I need to related with the query but i can't relate them