how to update target field with empty source value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2025 10:52 PM
hi, when I am updating the target field with empty value, the state is getting ignored, it is fetching empty value as null, I want if user give empty value for some field in portal, then the target field should be updated with empty values only, how to achieve it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2025 10:59 PM
Hi
Use onBefore transform script
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
if(source.FIELD_NAME.nil())
target.FIELD_NAME = '';
})(source, map, log, target);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2025 02:23 AM
hi, it is still not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2025 02:28 AM
can you share what script did you try so far and what debugging have you done?
You are talking about some field in portal but seems your response to other post talks about transform map.
It's confusing.
Can you please share your exact business requirement along with screenshot what you are talking about?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2025 02:57 AM
Hi @Amit Dey1 ,
You can set the 'Copy empty fields' check box of the transform map to true as shown below.
However, if you do so it will be applicable for all the fields present in field mapping. If you want this on only for some fields then for other fields you may write an onbefore script to ignore those specifically. Shown below.
if(source.FIELD1.nil() || source.FIELD2.nil() || source.FIELD3.nil()){
ignore = true;
}
If this address your question, please don't forget to mark this response correct by clicking on Accept as Solution and/or Kudos.
You may mark this helpful as well if it helps you.
Thanks,
Animesh Das