Why don't we have Phone type field on catalog item

uma17
Tera Guru

Hi All,

Any one has any idea why don't we have phone type field on catalog item?

Since we have Phone type field on sys_user table auto population of it on catalog item field does not match with our validations.

Thanks,

Uma

3 REPLIES 3

haseena ayesha
Kilo Guru

Hi Uma



Please go through the bellow links it may be help full to you:


Contact Type field - background rules? - ServiceNow Express Support


How to autopopulate catalog item variables using sys_user table




Thanks & Regards


Haseena


                                                                        PS: Hit like, Helpful or Correct depending on the impact of the response


lSurya 24
Giga Guru

Hello Uma,



Unfortunately, we don't have phone type in catalog item. But you write an on-change client script for validating the phone number on catalog item in order to match the phone number format on user table.



Here is the sample script:



function onChange(control, oldValue, newValue, isLoading) {


    if (isLoading || newValue == '') {


          return;


    }




      g_form.hideErrorBox('u_contact_number');


  // Allows formats of (999) 999-9999, 999-999-9999, and 9999999999


      var pattern = /^\d{3}\d{3}\d{4}$/; // You can add your regex here depending upon the format you need.


  if(!pattern.test(newValue)){


          //alert('Phone enter a valid phone number');


    g_form.showErrorBox('u_contact_number', getMessage('Invalid phone number'));//show error messege


          g_form.setValue('u_contact_number', '');



  }


 


}


Kalaiarasan Pus
Giga Sage

I do not think there is a universal format to represent phone numbers.


Different formats use characters such '()', '-', '+', etc. The best thing you can do is to write a regex based on the formats of phone numbers that are present on your system.