quarta-feira, 26 de agosto de 2015

Sample code: How to add Country Code to phone numbers in contacts personal names and address book

countrycode:="+55";

FIELD CellPhoneNumber := @If(CellPhoneNumber!="" & @Left(CellPhoneNumber;3)!=countrycode;
                                                          countrycode + @If(@Left(CellPhoneNumber;1)="0";
                                                                                                   @RightBack(CellPhoneNumber;1);
                                                                                                  CellPhoneNumber
                                                                                                  );
                                                           CellPhoneNumber
                                                        );

FIELD OfficePhoneNumber := @If(OfficePhoneNumber!="" & @Left(OfficePhoneNumber;3)!=countrycode;
                                                          countrycode + @If(@Left(OfficePhoneNumber;1)="0";
                                                                                                   @RightBack(OfficePhoneNumber;1);
                                                                                                  OfficePhoneNumber
                                                                                                  );
                                                           OfficePhoneNumber
                                                        );


FIELD PhoneNumber := @If(PhoneNumber!="" & @Left(PhoneNumber;3)!=countrycode;
                                                          countrycode + @If(@Left(PhoneNumber;1)="0";
                                                                                                   @RightBack(PhoneNumber;1);
                                                                                                  PhoneNumber
                                                                                                  );
                                                           PhoneNumber
                                                        );



This code does not cover all situations, for example, it does not expect that a number can be from another country, or that it does not already contain a local area code, or any other specific phone definition.

Also I do not provide any assurance regarding it. Use it at your own risk ;)

*´s / [ ]´s

Nenhum comentário: