I am looking to do a script that takes the callerid of the inbound caller and check it against a database before to route the calls to any CSQ. My problem is
the callerid is presented in a regular format, area code + phone number, and the dabatase is configured with (area code) + phone number. i.e: 1133189999 received
from PSTN, and configured at the database as (11)33139999.
How can i use set step on the script to include () to the area code before consult the database ?
You may also want to check that the number is 10 digits long before applying your manipulation and checking it against the DB (If callingNumber.length() == 10).
Thank you very much for your help, again. The calling number is always 11 digits. I receive the calling number from PSTN as 0+citycode+extension number,
ie: 07332158490. I need to have this number transformed to (73)32158490.
Sorry, perhaps I should have been a bit more clear. You'll need to start with stripping the 0 and then from there you can format the number using the other set step.
Does that make sense?
Thanks for help but it seems which is not working fine yet. Find below the results from set step.
calling number - 07332158490
after set step - (07)3215849
The correct translation should result in (73)32158490.
In your original example, you have a 10-digit calling number (1133189999); now you have an 11-digit calling number (07332158490), so the callingNumber.substring(3,10) is chopping off the last digit.
You could change it to callingNumber.substring(3,11) or you could use callingNumber.substring(3) and it should take the rest of the digits starting with the third one, independent of how many digits are in the string.
You would need to provide more detail on the possible inbound numbers, but my method for dealing with calls that come in with a '+' or leading '0' can be seen in the screenshot.
EDIT: This assumes that 0 is not a valid start for an area code in your corner of the world.