How to set a phone number on record producer?

s_s
Giga Contributor

Hello.

I created a variable to get the user to enter a phone number.

I would like to limit this variable as below.

・Only half-width numbers numbers can be entered.

・Set the maximum number of characters

Now, i set 'type' to 'Single Line Text' so should I change type too?

I appreciate it if you could answer.

1 ACCEPTED SOLUTION

Sanket Khabiya
Kilo Sage

Hi,

Please try with below solution:

Please write this code to you catalog Client Script



function onChange(control, oldValue, newValue, isLoading, isTemplate)
{
 if(isLoading || newValue==='')
 {
  g_form.showFieldMsg('mobile_no','number starting from 9/8/7 are valid','info');  //here mobile_no is your variable name
  return;
 }
 var phone = /^[789][0-9]{9}/;

 if(!phone.test(newValue)&& newValue!='')
 {
  g_form.setValue('mobile_no','');
  g_form.showFieldMsg('mobile_no','Please enter 10 digitvalid mobile number','error');
 }
}

Regards,

Sanket

View solution in original post

7 REPLIES 7

It doesn't work and Sorry I forgot to tell.

I created new field on the sn_customerservice_case to record to put the phone

number entered in the variable on the portal and the new filed type is 'String'

Also, the variable on record producer check 'Map to field'.

I don’t know if that ’s the case, u_phone_number is displayed as variable name.

find_real_file.png

modify the below line ,

var phone = g_form.getValue('u_phone_number');

 

you will use the variable name "u_phone_number" instead of "number"

Sanket Khabiya
Kilo Sage

Hi,

Please try with below solution:

Please write this code to you catalog Client Script



function onChange(control, oldValue, newValue, isLoading, isTemplate)
{
 if(isLoading || newValue==='')
 {
  g_form.showFieldMsg('mobile_no','number starting from 9/8/7 are valid','info');  //here mobile_no is your variable name
  return;
 }
 var phone = /^[789][0-9]{9}/;

 if(!phone.test(newValue)&& newValue!='')
 {
  g_form.setValue('mobile_no','');
  g_form.showFieldMsg('mobile_no','Please enter 10 digitvalid mobile number','error');
 }
}

Regards,

Sanket