Business Rule Examples

addJoinQuery(string Join Table,object primary field,object join table field):
adds filter to return a record based on relationship in related table
ex .
I have my user table where I have one field caller(referring user table)
Now I want such callers which are having incidents assigned to
I.e. Incident assigned to is same as my user caller

var p= new GlideRecord(“u_my_user”);
p.addJoinQuery(“incident”,”u_caller”,”assigned_to”);
p.query();
while(p.next()){
gs.print(“related records”+p.u_caller.name);
}

 

Encoded Query

var qq=”sys_created_on>javascript:gs.dateGenerate(‘2016-03-01′,’12:00:00′)^u_incident_numberISNOTEMPTY”;
var tt=new GlideRecord(“incident”);
tt.addEncodedQuery(qq);
tt.query();
while(tt.next()){
tt.u_task_number=tt.u_incident_number;
tt.setWorkflow(false);
tt.update();
tt.setWorkflow(false);
}

About the author

Leave a Reply