Can you help me for write script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2025 05:20 AM - edited 06-26-2025 05:26 AM
Requirements - create entity field in hardware table choices: asia, europe. create 2 location and based on those two locations if location A is selected then entity should automatically populated as Asia and if location is B then entity should populate as Europe. Whenever new record create or update or insert through transfer map
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2025 06:37 AM
Add the entity to the location record and use the dotwalked field from the location table on your target record.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2025 07:00 AM
that's not how you get display value of reference field.
update as this, ensure you use correct choice value to set the entity and don't use choice label
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var lName = g_form.getDisplayBox('location').value;
if (lName == 'A') {
g_form.setValue('u_entity', 'Asia');
} else if (lName == 'B') {
g_form.setValue('u_entity', 'Europe');
} else {
g_form.clearValue('u_entity');
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2025 08:07 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader