Import set to set a field to --None-- choice value instead of the default value in the dictionary

DaisyB057891995
Tera Contributor

Hi Team,

I have a choice field 'ABC' with default value set to 'XYZ'.

For a specific data source (import set), I want the choice field to set the value to --None-- instead of its default vallue 'XYZ'. What's the best way to achieve this as OnComplete transform script did not work because it runs just before the data is loaded to the target table.

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@DaisyB057891995 

you should use onAfter transform script and update the value as None

target.field = '';

target.update();

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

anshul_goyal
Kilo Sage

@DaisyB057891995, Use a “Run Script” Transform Map Field Mapping for That Specific Source.

You can achieve this within the Transform Map by adding a Field Map with a "Run script" option. Here's how:

Steps:

  1. Go to your Transform Map for the import set in question.

  2. Create a Field Map for the ABC field.

  3. Select "Run script" as the Mapping Type.

  4. Use a script like this:

// Clear the field value explicitly
target.ABC = '';

This script will override the default value and set the ABC field to empty (--None-- in the UI) only when the import set runs.

Feel free to mark this response as Accepted and Helpful for future reference.

Thanks

DaisyB057891995
Tera Contributor

Thank you both, but neither of them worked.

@DaisyB057891995 

Please share screenshots and more details about your transform map etc to help better.

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