How to populate a phone number(E164)when the territory selector is chosen from the drop down list

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2022 02:26 AM
How to populate a phone number based on the territory selector choice list Exampe: If the phone number is 13126266799 then North America needs to populated in the selector choice list same like if the phone number is +1 613-800-6513 then Canada needs to populated.
Anyone please help me on this.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2022 05:17 AM
In any case, if either the Phone number or the Country is to be selected from a list, you can make the 1st field o Select Box and you can configure a Service catalog data lookup:
to fill in the 2nd field.
Perhaps

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2022 10:39 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2022 04:46 AM
Well, I'm not sure why I thought this is about some Catalog Item, it clearly isn't. As for the original problem, the requirement is not supported OOB. Though it seems like one deals with two fields, the drop-down and the text entry are a single field and only the text entry is exposed through the g_form
API.
If you are OK with DOM manipulation a solution would be to create on onLoad Client Script for Incident that wires up an event listener, so you can know when the country has been selected:
function onLoad () {
var element = 'u_bridge_phone_number',
select = g_form.getControl('country_' + g_form.getTableName() + '.' + element);
if (select && typeof select.addEventListener == 'function')
select.addEventListener('change', callChange(select));
function callChange (select) {
var oldValue = getValueOfSelect(select);
onChange(select, oldValue, oldValue, true, false);
return function (event) {
onChange(event.target, oldValue, getValueOfSelect(event.target), false, false);
};
}
function getValueOfSelect (select) {
return select.selectedIndex > -1 ? select.options[select.selectedIndex].textContent : '';
}
function onChange (control, oldValue, newValue, isLoading, isTemplate) {
// This is where one can implement any logic that must run when the
// country is changed. E.g. do a GlideAjax call to fetch the number
// Based on newValue, which will be a label, like North America, etc...
if (isLoading || newValue === '') {
//return;
}
console.log('change', control, oldValue, newValue, isLoading, isTemplate);
}
}
You can than implement the lookup in function change, where the comments say. You should create lookup table to store the country - phone number list. With help of GlideAjax
, based on the selected label, you can obtain the phone number to use - this can be filled using the regular g_form.setValue()
call.
A week point of the solution (besides the DOM manipulation part and only working in UI16!, of course) is localization. The code uses the drop-down label for newValue
and oldValue
. This is to enable differentiation between Canadian and United Sates phone number which all start with 1+. But if an agent uses a non-English locale for himself, the label will no longer be in English and your solution will not work for him. This can be solved either by re-implementing function getValueOfSelect
to return something else and select the phone number by that value, or by selecting the phone number through a Decision Table based on localized labels.
Hope this all helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2022 05:15 AM
But there is in important fact to consider: it will NOT be possible to define two countries with the same calling prefix. So if you want both Canada and the United States to show up in the list of countries, well that is not possible. The two countries share the international prefix under North America. You could Create two new additional entries called Canada and United States using international prefixes +1780 and + 1312, but if anybody else will need to use Canadian or United States number with different prefixed, well, it is going to be messy.
If you ask me, I would just move the selection of the country into a different field, where the list of countries is NOT tied to the E164 validation tables (where only North America "can" exist).