- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-03-2020 05:19 AM
HI,
When I ma transforming a record for a specific Choice field when source.u_state is empty it enters a random choice for the record and does not update it as 'NONE' which is system default. I dont want to create another Choice value with None does not makes sense. Neither Copy empty fields work.
But then how can it be set to None when there is no value in that source.u_state? Any suggestions please.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-03-2020 05:33 AM
Hi,
sample script below
Ensure you give valid table name and the target field
Use source script for this field map
answer = (function transformEntry(source) {
// Add your code here
var tableName = 'incident';
var fieldName = 'category';
var rec = new GlideRecord('sys_choice');
rec.addQuery('name=' + tableName + '^element=' + fieldName + '^value=' + source.u_state);
rec.query();
if(rec.next()){
return rec.value;
}
return ""; // return the value to be put into the target field
})(source);
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
‎11-03-2020 09:36 PM
You are welcome
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader