Strip leading digit from Calling Number in UCCX 7

Unanswered Question
May 29th, 2009
User Badges:
  • Blue, 1500 points or more


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.

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 5 (4 ratings)
James Hawkins Fri, 05/29/2009 - 14:57
User Badges:
  • Blue, 1500 points or more

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.

vadimpunk Wed, 06/03/2009 - 00:09
User Badges:

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

James Hawkins Wed, 06/03/2009 - 02:10
User Badges:
  • Blue, 1500 points or more


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


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.

vadimpunk Wed, 06/03/2009 - 22:19
User Badges:

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:


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

James Hawkins Thu, 06/04/2009 - 01:31
User Badges:
  • Blue, 1500 points or more

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.



This Discussion