- 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:05 AM
Hi,
in that case you will have to use if else but the issue would be choice values won't be found
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:32 AM
if else also wont work 😞
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-03-2020 08:24 AM
Thanks for marking my response as helpful.
Let me know if I have answered your question.
If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.
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 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 11:51 AM
Hi Ankur,
Thanks it worked now the only change i made is instead of value I took Label since the values were different and also as integers. But this gave a good approach to make that work Thanks