The Zurich release has arrived! Interested in new features and functionalities? Click here for more

How to handle empty records in transform map script

SK36
Tera Contributor

Hi

I have wrote an transform map script and it will compare the staging table user id value with actual table user id value and if matching, it bring the user name from table.

The issue is , in the user table , it has 5 records with same "user id" in which one is correct record and 4 are duplicates records and username is empty.

Because of that my transform map showing error.

Here is my script.

var gr_user = new GlideRecord("sys_user");
gr_user.addQuery("employee_number", source.u_comp_manager_id);
gr_user.query();
while (gr_user.next()) {
var com_mrg_id = gr_user.user_name;
}
gs.log('print target+com_mrg_id);
return com_mrg_id;

 

How to restrict the empty records being executed through while loop? 

1 ACCEPTED SOLUTION

Aman Kumar S
Kilo Patron

You can just add one line just before gr_user.query() statement,

gr_user.addNotNullQuery("user_name");

 

Best Regards
Aman Kumar

View solution in original post

1 REPLY 1

Aman Kumar S
Kilo Patron

You can just add one line just before gr_user.query() statement,

gr_user.addNotNullQuery("user_name");

 

Best Regards
Aman Kumar