Transform map script ignore particular field update

sachin312
Giga Expert

Hi All,

We have LDAP Setup and a transform map configured to it. We have a 'onBefore' transform script.

if(action == "update") {

if(target.u_code == "100" || target.u_code == "1000") {

ignore = true;

      }

}

Because of the above script, the user records with code as '100' or '1000' are ignored from updating. This results in not updating the 'source' field for those users. How to update only source field without updating other fields??

Note: The main purpose of the onBefore script is we don't want to update the 'email' and 'user_name' fields of the users with code as '100' or '1000'.

3 REPLIES 3

HarshTimes
Tera Guru

Hi Sachin


In the transform script, write below code



  1. if(action == "update") {  
  2. if(target.u_code == "100" || target.u_code == "1000") {  
  3. ignore = true;    
  4.       }
  5. else{
  6. target.email = source.u_email ; //Check the correct field name form the source
  7. target.user_name = source.u_user_name ;//Check the correct field name from source
  8. }
  9. }  


Also, Make sure to remove the mapping of the email and username in field mappings of the transform script


Hi Harsh,



I don't think the above script will work for me. I think it works fine for "update", but if I remove field map of 'email' and 'username' fields then those fields wouldn't update during "insert" action.


Hi Sachin


You do not need to check for the action and you can directly put the if condition to check   code 100 & 1000.In this case for all insert and update action, script will check the code . If result satisfy then field will be mapped otherwise it will be ignored.



  1. if(target.u_code == "100" || target.u_code == "1000")
  2. ignore = true;
  3. }
  4. else{
  5. target.email = source.u_email ; //Check the correct field name form the source
  6. target.user_name = source.u_user_name ;//Check the correct field name from source
  7. }