Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

OnBefore Transform Script to ignore insert if no record found in gliderecord table:

patricialynch
Giga Contributor

I am trying to run an onbefore transform script to check the following

The source employee id to the sys_user employee_number

If no match found ignore the record and do not indert

This is not working

It is still creating records with no user

var empId = source.u_employee_id;

var gr = new GlideRecord('sys_user');

gr.addQuery('employee_number', empId);

gr.query();

while(!gr.next()){

  if(action == insert){

  ignore = true;

}

}

I have also tried

if(!gr.next()){

ignore = true;

}

That doesn't work either

What am I missing?

Thank you

5 REPLIES 5

ProbirDas
Tera Expert

Open the Field map for the mapping - source employee id to the sys_user employee_number



There, you will find the field "Choice Action", select Ignore