Where is extra encoded query coming from and what does it mean?

Viewed 331

I've the following in a SI

var serviceAsset=new GlideRecord('u_service_asset');
serviceAsset.addQuery('u_service',service_sys_id);
serviceAsset.addNotNullQuery('u_parent');
serviceAsset.query();
gs.log(serviceAsset.getEncodedQuery());

This prints the following in the logs

u_service=305baa6fdb17d0d44bb6e126059619e1^u_parent!=NULL^sys_idNotValidnull^ORsys_idNotValidnull

What does sys_idNotValidnull mean and why is it getting added as an OR condition?

I've a "Query" Business Rule on the table but that code doesn't seem to be referencing the above.

Business Rule code

(function executeRule(current, previous /*null when async*/) {  
    
    var serviceassetquery;
    serviceassetquery = current.addEncodedQuery("u_sourcesystem!=Wholesale^ORu_sourcesystem=NULL");
    
})(current, previous);
2 Answers

Assuming sys_idNotValidnull means "referred sys_id is not exist".

The easiest and best way to get an encoded query as follows:

  1. Navigate to the table.
  2. Build filter and run
  3. Right-click on the bread crumb (You will see copy query option that will give proper encoded query, Please refer to the screenshot attached)

Example of copied query: "active=true^state!=10^ORstate=^sys_idISNOTEMPTY"

enter image description here enter image description here

So the

sys_idNotValidnull^ORsys_idNotValidnull

part was being added by the Business Rule. And the reason for sys_idNotValidnull presence was because the column u_sourcesystem was NOT present on the table u_service_asset

Duh! It was an invalid column after all that caused all the issue.

Related