How to prevent list collector field in transform map from being updated with invalid data
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
I have created a transform map and have a list collector field which I am able to update with invalid choices. I've tried setting the choice action to ignore and reject but the field still gets updated.
As a workaround I can restrict the import sheet to only allow the user to select valid choices but I also want restrict it in Servicenow so they can't enter any bad data. They should be able to select multiple choices and update these through the transform.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Unfortunately I havent had any luck with this. I have tried using a onBefore script & removing mapping.
Also tried using a source script on the field mapping but still seeing invalid data being populated.
The onBefore script I used is:
(function transformEntry(source, target, map, log, isUpdate) {
// Skip insert if not an update
if (!isUpdate) {
ignore = true;
return;
}
// Validate 'Type of HC Data'
var validHCData = [
'Other',
'Technical / Procedural security arrangements',
'Business Manager'
];
if (!validHCData.includes(source.u_type_of_hc_data.toString())) {
target.u_type_of_hc_data = ''; // or null
}
// Validate 'PCI DSS capacities'
var validPCI = [
'Service Provider',
'Security Impacting',
'Issuer',
'Connected System'
];
if (!validPCI.includes(source.u_pci_dss_capacities.toString())) {
target.u_pci_dss_capacities = ''; // or null
}
})(source, target, map, log, action === 'update');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
so when you added gs.info() what are your findings?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I'm seeing this in the logs:
The source field is being updated with 'Merchant, testing, testing1' despite the invalid data getting filtered.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
you need to query sys_choice and see if that choice is present in list collector
then try to set the choice value using target object
💡 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 || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
I have tried that and also made sure to test with choices that aren't present in list collector but experiencing the same issue still. Not sure if there are any other workarounds for this
