Set default Caller phone number field to a specific region on IMS Interaction Record

Xavier_Wharton
Giga Guru

Hello Community, 

I need help configuring the dictionary entry for the 'caller_phone_number' field on the IMS record. 
Please review the information below and let me know if you have any questions. 

I want to set the field's default value to "North America." 

Xavier_Wharton_1-1748307472446.png

 

I have tried two different approaches, but with no luck:
1. Typing the Default Value field to North America
2. Changing the Attributes field to "phone_number_default_region=US"  

Xavier_Wharton_0-1748307422013.png

 

1 ACCEPTED SOLUTION

Xavier_Wharton
Giga Guru

I was able to make it work using a Client Script (onLoad). 
I made a video with some additional context that you can click the link below:
https://youtu.be/hOb1dx20qtw 

Steps to reproduce:

  1. Show the "Caller Phone Number" field on the following form views:
    • Default
    • Service Operations Workspace
    • Service Operations Workspace New Record
  2. Navigate to All > System Definition > Client Scripts
  3. Click the "New" button on the top right
  4. Enter the following in the fields on the new record:
    • Name: Set Default Phone Region to [InsertRegion]
    • Table: Interaction [interaction]
    • UI Type: All - Unless you want only Desktop or only Mobile
    • Type: onLoad
    • Active: True ☑️
    • Global: True ☑️
    • Description

      Sets the default value of the Caller Phone Number field (+1) for new Interaction records to simulate a North America default region for E.164 phone format.

    • Script:
function onLoad() {
    if (g_form.isNewRecord()) {
        var currentValue = g_form.getValue('caller_phone_number');
        if (!currentValue) {
            // Set default country code to +1 for North America (US).
            // Replace "+1" with your region's country code if different.
            g_form.setValue('caller_phone_number', '+1');
        }
    }
}

View solution in original post

Review the community post below: https://www.servicenow.com/community/sysadmin-forum/set-default-caller-phone-number-field-to-a-specific-region-on/m-p/3273933#M18534
1 REPLY 1

Xavier_Wharton
Giga Guru

I was able to make it work using a Client Script (onLoad). 
I made a video with some additional context that you can click the link below:
https://youtu.be/hOb1dx20qtw 

Steps to reproduce:

  1. Show the "Caller Phone Number" field on the following form views:
    • Default
    • Service Operations Workspace
    • Service Operations Workspace New Record
  2. Navigate to All > System Definition > Client Scripts
  3. Click the "New" button on the top right
  4. Enter the following in the fields on the new record:
    • Name: Set Default Phone Region to [InsertRegion]
    • Table: Interaction [interaction]
    • UI Type: All - Unless you want only Desktop or only Mobile
    • Type: onLoad
    • Active: True ☑️
    • Global: True ☑️
    • Description

      Sets the default value of the Caller Phone Number field (+1) for new Interaction records to simulate a North America default region for E.164 phone format.

    • Script:
function onLoad() {
    if (g_form.isNewRecord()) {
        var currentValue = g_form.getValue('caller_phone_number');
        if (!currentValue) {
            // Set default country code to +1 for North America (US).
            // Replace "+1" with your region's country code if different.
            g_form.setValue('caller_phone_number', '+1');
        }
    }
}
Review the community post below: https://www.servicenow.com/community/sysadmin-forum/set-default-caller-phone-number-field-to-a-specific-region-on/m-p/3273933#M18534