Search code examples
javascriptservicenow

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


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);

Solution

  • 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.