How to clear out the value on a form via a transform map
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
In my instance, I'm wanting to clear out the value of the 'IBP Tier' field of the below Application Service (cmdb_ci_service_discovered) record:
However, I only want users to be able to do this if they enter 'Null', 'NULL' or 'null' in the spreadsheet of the transform map as seen below:
I'm using the below field mapping:
However, when I run my transform, I find that it's not clearing out the 'IBP Tier' field. I was just wondering if anywhere knows what I need to do to clear the 'IBP Tier' field out.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @matthew_hughes Now that you're using Ignore, there's no need to write a script. If the choice doesn't match automatically, it won't fill the value. It will only fill if the choice value matches. Remove the script, just return the value and check.
return source.u_cbp_tier;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
use onBefore transfrom script instead of field map script
// Normalise the value (handles NULL, null, Null, etc.)
var tier = (source.u_cbp_tier + '').trim().toLowerCase();
// If the value is "null", clear the target field
if (tier == 'null')
target.fieldName = '';
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader