cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3557
Views
20
Helpful
6
Replies

Strip leading digit from Calling Number in UCCX 7

James Hawkins
Level 8
Level 8

Hi,

I have a script which uses the Get Call Contact step to read the Calling Number of a contact and store it in a string.

The calling number is manipulated by the H.323 gateway to add the PSTN access code "9" so that users can directly return calls from their phone logs without editing the number. For example, if a caller with the number 02082363299 calls the calling number is set to 902082363299.

This causes me a problem in my script as I want to play the number as a generated prompt to the caller and do not want them to hear the initial 9.

Can anyone tell me how I can manipulate the contents of the string storing the number to strip off the initial digit?

I have thought changing the contents of the string to an integer and subtracting 900000000000 but this would also lose the second digit which would always be a zero.

I anyone can suggest how I can do this I would be most grateful.

6 Replies 6

James Hawkins
Level 8
Level 8

Found the answer.

Assuming that the 902082363299 number is in a string called CallingNumber and the result is to be stored in ResultNumber

Use a SET step with the variable ResultNumber and value CallingNumber = CallingNumber.substring(1, CallingNumber.length())

A sample script which also generates and plays a prompt to announce the number is attached for those who want to do the same thing.

Thank you very much for your script, but can you tell me how i should modify this:

CallingNumber.substring(1, CallingNumber.length())

If I want to drop the last 1-2 digits not the first.

For example if i have this number 83719063095, I want to make 837190630

Hi,

I am not a Java expert by any means but I think the following would work.

CallingNumber.substring(0,-2)

0 is the "startIndex" and specifies the beginning index. -2 is the "endIndex" and specifies the stopping point.

0 tells the system to start from the first character (8 in your example). -2 tells the system to stop two characters from the end (0 in your example).

Let me know if this works.

Thanks again.

The example you mentioned CallingNumber.substring(0,-2) doesn't work, I had an error which sad that string index -2 is out of range.

Than I played with this (0,-2), and found that for my example, if I want to drop last 2 digits, it should be like this:

CallingNumber.substring(0,9)

It drops nothing from the beginning and saves only first 9 digits.

Hi vadimpunk,

I am glad that you managed to get the script to do what you needed.

Your solution would be fine for fixed length numbers but, if you need to do the same thing for variable length numbers, the following expression would work.

CallingNumber.substring(0, (CallingNumber.length())-2)

I have updated my script to include this. It also now uses the Get Call Contact step to read the calling number rather than just reading out the static string of the original script.

Hi jamesha,

Very helpful script, thanks

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: