Script Transform Map

yoli1
Tera Contributor

Hello everyone

2 REPLIES 2

Riya Verma
Kilo Sage
Kilo Sage

Hi @yoli1 ,

 

Hope you are doing great.

 

Here's a user-friendly, professional solution for the ServiceNow query:

  1.  navigate to the "Import Sets" module in ServiceNow.
  2. Select the appropriate Import Set Table that corresponds to your source table.
  3. Click on "Field Maps" to configure the field mapping between the source and target tables.

let's add a script to the field mapping to perform the required transformation:

 

(function transformMap(source, target, map, log, isUpdate) {
    // Get the value from the source field
    var sourceValue = source.email.toString();
    
    // Replace '-' with '@' in the source value
    var transformedValue = sourceValue.replace(/-/g, '@');
    
    // Set the transformed value to the target field
    target.email = transformedValue;
})(source, target, map, log, action === 'update');

 

 
Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma

yoli1
Tera Contributor

@Riya Verma Thank you