LDAP Transform map script Issue

jlaps
Kilo Sage

We use the CITY field from AD (which comes from HR system) to drive the location field in Servicenow. This works fine, except for Canada users that are remote, because HR uses the same city for CA remote users as they do for US remote users (REMOTE). The city is remote, and even though both the USA - REMOTE and CA - REMOTE locations have "remote" for the city, it looks like everyone is USA - REMOTE when the LDAP sync occurs.

The country is correct however.

 

I am thinking that I should be able to fix this in the script on the transform map, but perhaps I am incorrect... is is possible to reference other fields when 'answering' the city field? This is what I have tried so far, but it does not work.

 

Ideas?

 

 

var gr = new GlideRecord('cmn_location');
gr.addQuery('city', source.u_l);
gr.query();
if(gr.hasNext())
      if(source.u_l != 'Remote' || source.u_l =='Remote' && source.u_c == 'US')
         answer = source.u_l;
      if(source.u_l =='Remote' && source.u_c == 'CA')
         answer = 'CA Remote';
else
   answer = 'Telecommuter';

 

 

1 REPLY 1

Mani A
Tera Guru

// Example transform map script
(function transformRow(source, target, map, log, coalesce) {
var city = source.city;
var country = source.country;

// Determine location
if (city == 'REMOTE') {
if (country == 'USA') {
target.location = 'USA - REMOTE';
} else if (country == 'Canada') {
target.location = 'CA - REMOTE';
} else {
target.location = 'REMOTE - OTHER';
}
} else {
target.location = city; // Default or handle other cases
}

// Map other fields as needed
})(source, target, map, log, coalesce);