We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

GlideRecord addQuery comparing two field values

toneyvecchio1
Tera Expert

Greetings,

I was hoping for assistance, likely a simple answer but too much time has been spent already trying 70 different methods and I am sure someone here will know it.

Stripped down to its basic form I am trying to addQuery against 1 field on a table and 1 field on another table, stepping through a reference field.

var getCvr = new GlideRecord('pm_portfolio_project');

getCvr.addQuery('project.u_start_date','=','u_project_start_date');

getCvr.query();

while(getCvr.next()) {
//do stuff

getCvr.update();
}

I have confirmed the project.u_start_date works fine, I am assuming its comparing 'u_project_start_date' as a literal string and not evaluating the field from the original table. Any advise?

1 ACCEPTED SOLUTION

Replace the addquery with this


getCvr.addEncodedQuery('pm_project.start_dateSAMEASstart_date@day')



If this doesn't work, open the table > filter the record as needed > right click on the query end >do a copy query> use it in encoded query


View solution in original post

5 REPLIES 5

  1. var getCvr = new GlideRecord('pm_portfolio_project');  
  2. getCvr.addQuery('project.u_start_date',current.u_project_start_date);   // if field is located on current record where BR is firing (eg. if BR is configured on table A, current will point to Table A record
  3. getCvr.query();  
  4. while(getCvr.next()) {  
  5.           getCvr.u_gtg_plan = 'Found a match';  
  6.           getCvr.update();  
  7. }  





  1. var getCvr = new GlideRecord('pm_portfolio_project');  
  2. getCvr.addQuery('project.u_start_date',getCvr.u_project_start_date);   // compare same record two fields if both fields are pointing toward 'pm_portfolio_project
  3. getCvr.query();  
  4. while(getCvr.next()) {  
  5.           getCvr.u_gtg_plan = 'Found a match';  
  6.           getCvr.update();  
  7. }  




Though your question is now answered, you can try with above two codes as well