- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2022 04:01 PM
Hi, I have a scenario where if I get any value that doesn't exist in choice list (target table field is a choice list where label and field = ABC). The issue is how to set the target field value to the default value as 'ABC'. Please help me with this. Thanks.
If(source.u_company_name == 'ABC' || source.u_company_name == 'DEF'){
ignore =false;
} else {
target.u_company_name = 'ABC'; // not able to get this set
ignore =true;
}
Solved! Go to Solution.
- Labels:
-
Cost Management (ITSM)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2022 08:31 AM
Glad to know that my script worked.
Thank you for marking my response as helpful.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2022 04:54 PM
Hi Praveen,
Instead of writing the above code in the transform map's script, create a field map and use the source script. as per the below example shown in the screenshot, you can see the target field "IT Profile" is a list type of field and we are setting up the default as "Traditional Worker " when it is not getting any matching value so you can use the same concept in your case. Make sure to choose choice action as ignore otherwise it will create new choice values. Thanks.
Please mark my answer as helpful if that solves your concern. Thanks in advance!
Regards,
Nayan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2022 06:57 PM
I have tried this way. But when I load the records, getting the null pointer exception. Not sure why.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2022 07:03 PM
Hi Praveen,
Can you show me the screenshot of the script, and the error, please? And make sure to return correct choice values? Thanks.
Regards,
Nayan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2022 04:55 PM
Hi, you don't make it clear if this is a field transform or before transform script?
I assume a before transform based on the format and use of 'target' ?
Looking at your code you are setting ignore = true, which will mean that your row insert\update for the record being processed will be ignored., so no record is processed against which the default value will be set.
What happens if you remove ignore = true?
Also ignore = false is implied and is not required, unless you are setting ignore = true earlier in your script?