You need to sign in to do that
Don't have an account?
Waleed Alkhudairi
how to add prefix before field value in salesforce using dml
Hi All,
I have phone field that i need to add "+" or 00 to dial for country how can i add this prefix using dml statments. here is my current one:
i want to add ' + then c.MobilePhone
I have phone field that i need to add "+" or 00 to dial for country how can i add this prefix using dml statments. here is my current one:
list <lead>cs = [select name, id, phone, MobilePhone from lead]; for (lead c:cs) { c.Phone= c.MobilePhone; } Update cs;
i want to add ' + then c.MobilePhone
May I suggest you please refer to below link with a similar discussion which might help you further.
- https://developer.salesforce.com/forums/?id=9060G000000ICJ9QAO
Please let us know if this helps.Thanks,
Nagendra
Please mark this as Best Answer, if this helps solve your problem.
Step 1 : - Create a Custom Metadat with the Country Name and Its Prefix .
Step 2 : In the trigger get the all the custom metadata type ang get the contact country and do the perfix assigmenet
try this code
Please mark this as BEST ANSWER, if this helps solve your problem.
I modified the code you posted in code.
Please change field API names if required.
in the code that I provided, any value in Phone will be overwritten by the value from MobilePhone field. However, if you want data to be copied in the same field, simply use
c. Phone = '+' + c.Phone;
or
c.MobilePhone = '+' + c.MobilePhone;
similarly make changes at other places as well