2

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);
asprin
  • 9,579
  • 12
  • 66
  • 119

2 Answers2

1

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

Ruben Helsloot
  • 12,582
  • 6
  • 26
  • 49
Mr world wide
  • 4,696
  • 7
  • 43
  • 97
1

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.

asprin
  • 9,579
  • 12
  • 66
  • 119