Need to write a code in LDAP Transform Map

Chhavi Dixit
Tera Contributor

Hi Everyone,

 

I need to write a code in LDAP Transform Map, Transform map already created on sys_user table.

 

If Employee Type is updating then Supplier Company value should be cleared.

 

Thanks!

Chhavi Agnihotri

 

 

1 ACCEPTED SOLUTION

@Chhavi Dixit 

yes that BR logic will work in both cases when somebody updates the employee type and also when transform map runs.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

9 REPLIES 9

Ankur Bawiskar
Tera Patron
Tera Patron

@Chhavi Dixit

So employee type is coming from LDAP? Did you check this?

You can use onBefore transform script for this and set the target supplied company as empty

Something like this but please enhance

Give correct source and target fields

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

    // Add your code here
    if (source.u_employee_type != target.employee_type && action == 'update')
        target.supplierCompanyField = '';

})(source, map, log, target);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thanks @Ankur Bawiskar  for quick response.

It will work.

 

But now requestor is asking me to do it via Business Rule.

 

Thanks!

Chhavi Agnihotri

@Chhavi Dixit 

Thank you for marking my response as helpful.

I believe I answered your original question.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Chhavi Dixit 

Inform the requestor that it's recommended to handle this via onBefore transform script since you can re-use the transform script

why to create business rule?

if you want to handle via business rule then you can do this

BR: Before Update

Condition: Employee Type Changes

Script:

current.supplied_company = '';

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader