- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2020 03:58 AM
Hi There,
This is what I need to do: I have a field "Requester country" which I need to fill when Request is created, based on country of Requester.
Requester has an attribute of country, but it is in long ISO code (3 letters) instead of country name. I have country names mapped to ISO codes in "Country" table and "Requester country" is a reference field to that table. How to make that instead of ISO code from user record, field will be updated with full country name?
Current code used to fill Request fields (based on call) is something like this:
var grRequest = new GlideRecord ("sc_request");
grRequest.initialize();
// copy fields from call to req
grRequest.requested_for = current.opened_by;
grRequest.opened_by = current.opened_by;
grRequest.u_region_high_level = current.u_call_region_high_level;
grRequest.u_requester_email = current.u_call_requester_email;
grRequest.u_requester_name = current.u_call_requester_name;
(...)
//I was trying to use line below but I know it can't work since it is updating ISO code and not full name.
grRequest.u_requester_country = current.u_call_requester_name.country;
(...)
Could you please help me with that?
Regards,
Kuba
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2020 04:02 AM
Hi,
Is this field a reference type "u_call_requester_name"?
to which table it refers?
you will have to do something like this
var rec = new GlideRecord('country'); // give proper country table name here
rec.addQuery('iso_field', current.u_call_requester_name.country); // give valid iso field here
rec.query();
if(rec.next()){
grRequest.u_requester_country = rec.sys_id;
}
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
‎08-23-2020 04:41 AM
Hope you are doing good.
Let me know if that 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