Skip to main content
Added known details
Source Link
KSL
  • 532
  • 2
  • 10
  • 28

In contact object, I have phone number field which is type of Phone. The current value is 8767876541. The problem is it is not displaying in correct format. The format which I am looking out is (876)787-6541 . When I click on that field by manually its getting formatted into expected way. the problem is I have 2000+ contacts with wrong format and I want to update all of them through some code.

So I tried the below code for one record to see if that updates the Phone field in correct format.

List myobjects = [ Select Id,Name,Phone From contact where Id='0033600000LMk8M']; for( Contact myobject : myobjects ) { myobject.Phone = '2159003935' ; }

update myobjects;

But it didn't help me to make the phone number into correct format

I checked it through some stack exchange questions and the answer is showing as

" Any entry of phone numbers through the API does not receive formatting. Please let me know how to handle"

Any solution on this issueplease

In contact object, I have phone number field which is type of Phone. The current value is 8767876541. The problem is it is not displaying in correct format. The format which I am looking out is (876)787-6541 . When I click on that field by manually its getting formatted into expected way. the problem is I have 2000+ contacts with wrong format and I want to update all of them through some code.

So I tried the below code for one record to see if that updates the Phone field in correct format.

List myobjects = [ Select Id,Name,Phone From contact where Id='0033600000LMk8M']; for( Contact myobject : myobjects ) { myobject.Phone = '2159003935' ; }

update myobjects;

But it didn't help me to make the phone number into correct format. Please let me know how to handle this issue

In contact object, I have phone number field which is type of Phone. The current value is 8767876541. The problem is it is not displaying in correct format. The format which I am looking out is (876)787-6541 . When I click on that field by manually its getting formatted into expected way. the problem is I have 2000+ contacts with wrong format and I want to update all of them through some code.

So I tried the below code for one record to see if that updates the Phone field in correct format.

List myobjects = [ Select Id,Name,Phone From contact where Id='0033600000LMk8M']; for( Contact myobject : myobjects ) { myobject.Phone = '2159003935' ; }

update myobjects;

But it didn't help me to make the phone number into correct format

I checked it through some stack exchange questions and the answer is showing as

" Any entry of phone numbers through the API does not receive formatting."

Any solution on this please

edited tags
Link
Adrian Larson
  • 151.4k
  • 38
  • 247
  • 431
Source Link
KSL
  • 532
  • 2
  • 10
  • 28

Phone number field formatting

In contact object, I have phone number field which is type of Phone. The current value is 8767876541. The problem is it is not displaying in correct format. The format which I am looking out is (876)787-6541 . When I click on that field by manually its getting formatted into expected way. the problem is I have 2000+ contacts with wrong format and I want to update all of them through some code.

So I tried the below code for one record to see if that updates the Phone field in correct format.

List myobjects = [ Select Id,Name,Phone From contact where Id='0033600000LMk8M']; for( Contact myobject : myobjects ) { myobject.Phone = '2159003935' ; }

update myobjects;

But it didn't help me to make the phone number into correct format. Please let me know how to handle this issue