Update field values based on a field via import file

PoorvaB
Tera Contributor

Hi Community,

 

I have an import file which contains employee number and 2 other fields. Based on employee number, i need to update 2 other fields values. 

 

What is the best approach to update those fields based on employee number? Do i need to use import sets or background script to do this?

 

What exact steps i need to follow for this?

 

Thanks,

Poorva Bhawsar

1 ACCEPTED SOLUTION

Debasis Pati
Tera Guru

Hello @PoorvaB ,

  • Create an Import Set Table:

    • Navigate to System Import Sets > Load Data.

    • Create a new Import Set Table and upload your file containing the employee number and the two other fields.

  • Create a Transform Map:

    • Navigate to System Import Sets > Administration > Transform Maps.

    • Create a new Transform Map and map the fields from your Import Set Table to the target table (e.g., sys_user if you're updating user records).

    • Ensure you map the employee number field to the corresponding field in the target table.

  • Define Field Mapping:

    • In the Transform Map, define the field mappings for the two fields you want to update based on the employee number.

    • Use the Coalesce field to identify the unique record. Set the employee number field as the coalesce field. This ensures that the existing records are updated rather than creating new ones.

  • Script for Field Update:

    • If you need to perform additional logic or transformations, you can use a Transform Script. For example:

(function transformRow(source, target, map, log, isUpdate) {
// Update the target fields based on the source fields
target.field1 = source.field1;
target.field2 = source.field2;
})(source, target, map, log, isUpdate);


 

  • Run the Transform:

    • Navigate to System Import Sets > Load Data.

    • Select your Import Set Table and click on Transform.

    • Choose the Transform Map you created and run the transform.

  • Verify the Data:

    • After the transform is complete, verify that the fields have been updated correctly in the target table.

      Please Mark it as correct/helpful if this resolves your query.

      Regards,
      Debasis

 

 

View solution in original post

18 REPLIES 18

@PoorvaB 

Glad to know.

As per new community feature you can mark multiple responses as correct.

If my response helped please mark it correct as well so that it benefits future readers.

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

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @PoorvaB 

 

The best approach is import set. where you can bring data in SN or update  well. 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Robbie
Kilo Patron
Kilo Patron

Hi @PoorvaB,

 

Best practice and easiest approach would be to Load the data and use Transform Maps. Keeping it high level, probably the most compelling reason for this apart from it's ease is the fact the data is loaded into a staging table providing full visibility and traceability.

 

Check the below ServiceNow Leaning link which walks you through how to both load the data and how to create a transform map:

https://developer.servicenow.com/dev.do#!/learn/learning-plans/xanadu/new_to_servicenow/app_store_le...

 

 

To help others (and for me to gain recognition for my efforts), please mark this response correct by clicking on Accept as Solution and/or Kudos.




Thanks, Robbie

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @PoorvaB 

 

I think to appreciate, you can accept everyone's answer here, as @Ankur Bawiskar  @Robbie  and myself also supported you and guided you to complete this requirement.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************