cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
5603
Views
40
Helpful
11
Replies

UCCX Calling Number

Carl Ratcliffe
Level 3
Level 3

Hi Support Community

I am using a script for which i need to route calls based on the Calling Number. If they come from extension 3XXX they go to agents located at 1 site as first priority and if they come from extensions 4XXX they go to another site first. This all works fine with my current setup :

  • Get Call Contact Info step to capture calling number and populate a variable called CallingNumber
  • I then use an 'set' step to populate a 'int' variable named CallingNumber_INT with the value 'int.parseInt(CallingNumber)'
  • I then use if nodes to match the calling number ranges and direct the call.
  • Anything that is not matched is sent to another site as first point of call so for example extension 8XXX

The above is all working good however its all based on callers from an internal extension. I now need allow calls from external sources ( these could be any location - country, landline, mobile etc ). The calling number for these wont be defined for call routing they should just not match a defined extension and are therefore false in the IF statement and sent to the site defined above. I didnt think i would have to change anything on my script but it isnt working for any external callers.

I have 2 different scenarios but both maybe the same solution, an unknown caller cli so populated as '0' in the CallingNumber variable and a correct cli for example 212XXXXXXX which is also populated in the CallingNumber variable. When any external number dials in the script playes 'im sorry we are currently experiencing system problems'. When i debug the script i get the following error :

Exception : For Input String: "212XXXXXXX"; nested exception is: java.lang.NumberFormatException: For input string "212XXXXXXX" ( line:1, col:1)

Any advise would be appreciated.

Carl Ratcliffe

2 Accepted Solutions

Accepted Solutions

Firstly, drkchiloll is correct about NANP exceeding the MAX_VALUE (2147483647) of integers which could cause the exception to be thrown.

Second, why are you processing the number as an integer at all? From the script provided it seems you only have one requirement:

If the area code is 330 the customer location is from New York

If the area code is 331 the customer location is from New Jersey

If either condition above is not true, the customer location is defined as "External"

With that in mind, what you want to accomplish is very simple. Simply extract the area code from the Calling Number, test against those conditions and set your customer variable appropriately.

The first have is easily accomplished via the substring() method, the latter via a Switch STEP as seen below:

One benefit is you are not playing against data types. The other is you are not comparing against a range of numbers which is just sloppy and cumbersome.

Now this is a simple usecase and maybe that's enough for you, but this sets you up for greater expansion. In the event you want to match against, say 100 area codes and assign value appropriately you can begin to leverage external data stores. Be it an XML document, database or otherwise. Imagine putting integer comparisons for 100 area codes; tedious no?

If you go with the above example, make sure to format your number correctly. substring(0,3) may not caputre the area code if you have +1 in front of the number or an access code for instance.

I would like to add, from the above example you may consider testing against the length of CallingNumber before processing substring; for example:

if (CallingNumber.length() > 10) 

     True:

          /* process number with substring(); */

     False:

          /* test against "unknown" number 0 */

          if (CallingNumber == "0")

               True:

                    /* external caller with unknown number */

               False:

                    /* probably an internal caller */


Otherwise, substring(0,3) as above would throw an exception on the step if the number was "0".

Which brings me to the last point. Consider putting On Exception GoTo and catching either specific exceptions if you know what they are, or ExpressionException if you do not. From there you can recover from a failure and continue processing.

Best of luck.

Regards,

Tanner Ezell
www.ctilogic.com

Tanner Ezell www.ctilogic.com

View solution in original post

Carl,

I'm glad to hear it. There should be a simple solution to your matching, instead of

if (CallingNumber == "0")

You could use:

if (CallingNumber == "" || CallingNumber == null)

This will catch bull null values and blank. Catching null is probably not necessary but it does add an additional level of testing.

I suspect you need to move the "On Exception GoTo" step up in your script, right before you call substring() in the SET step.

For substring() you pass along where you want to begin splicing characters from and where you want it to end. As such, CallingNumber.substring(0,3) is saying:

"I want the substring of CallingNumber starting at character 0 and ending at character 3 returned"

If you have the variable, CallingNumber as "3305551234", it looks like this:

CallingNumber[0] = "3"

CallingNumber[1] = "3"

CallingNumber[2] = "0"

CallingNumber[3] = "5"

CallingNumber[4] = "5"

CallingNumber[5] = "5"

CallingNumber[6] = "1"

CallingNumber[7] = "2"

CallingNumber[8] = "3"

CallingNumber[9] = "4"

Note as you might notice, CallingNumber[3] is not included. That is because according ot the definition of substring(startIndex, endIndex), startIndex is inclusive (meaning it is included in the return) and endIndex is exclusive (meaning it is not included in the return).

I hope this has helped shed some light on what is happening.

Regards,

Tanner Ezell
www.ctilogic.com

Tanner Ezell www.ctilogic.com

View solution in original post

11 Replies 11

Samuel Womack
Level 5
Level 5

Is there any way you can provide a testable script by pulling the relevant steps out of your current script and providing them here? 

Hi, please see attched script. All the relevant information is included.

Basically if CallingNumber is 330XXXX it works correctly ( routes to a CSQ that isnt in the script ), the same goes for a CallingNumber of 331XXXX.

Any external CLI ( populates CallingNumber correctly ) or unknown number fails at the set step 'CallingNumber_INT'.

Thanks, Carl

For Unknown number I don't see problems if the CallingNumber Variable is actually "0".  Can you actually Confirm this?

Regardless, try the attached file and verify it operationally.  What makes me uneasy about the String Number Conversion is external numbers can be so close to "overflowing" your INT that I wouldn't use that DataType at all (use LONG).  What I provided will work with UNKNOWN as well because I'm using a TRY/CATCH Block that will Throw the NumberExceptionFormat Exception..but continue processing..and the LONG will be set to a value of 0..Let me know if this helps..

Firstly, drkchiloll is correct about NANP exceeding the MAX_VALUE (2147483647) of integers which could cause the exception to be thrown.

Second, why are you processing the number as an integer at all? From the script provided it seems you only have one requirement:

If the area code is 330 the customer location is from New York

If the area code is 331 the customer location is from New Jersey

If either condition above is not true, the customer location is defined as "External"

With that in mind, what you want to accomplish is very simple. Simply extract the area code from the Calling Number, test against those conditions and set your customer variable appropriately.

The first have is easily accomplished via the substring() method, the latter via a Switch STEP as seen below:

One benefit is you are not playing against data types. The other is you are not comparing against a range of numbers which is just sloppy and cumbersome.

Now this is a simple usecase and maybe that's enough for you, but this sets you up for greater expansion. In the event you want to match against, say 100 area codes and assign value appropriately you can begin to leverage external data stores. Be it an XML document, database or otherwise. Imagine putting integer comparisons for 100 area codes; tedious no?

If you go with the above example, make sure to format your number correctly. substring(0,3) may not caputre the area code if you have +1 in front of the number or an access code for instance.

I would like to add, from the above example you may consider testing against the length of CallingNumber before processing substring; for example:

if (CallingNumber.length() > 10) 

     True:

          /* process number with substring(); */

     False:

          /* test against "unknown" number 0 */

          if (CallingNumber == "0")

               True:

                    /* external caller with unknown number */

               False:

                    /* probably an internal caller */


Otherwise, substring(0,3) as above would throw an exception on the step if the number was "0".

Which brings me to the last point. Consider putting On Exception GoTo and catching either specific exceptions if you know what they are, or ExpressionException if you do not. From there you can recover from a failure and continue processing.

Best of luck.

Regards,

Tanner Ezell
www.ctilogic.com

Tanner Ezell www.ctilogic.com

Thank you Tanner

I will take a look at your recomendations and test.

Carl

Thank you also drkchillol

Hi Tanner

I have implemented your advice and it works great using the substring and switch step. So much easier than matching ranges which is as you said cumbersome and sloppy.

I still have a query regarding the unknown number cli's. The CallingNumber is actually blank so "" not "0" as i previosuly mentioned. I tried to put a step of "on exception go to" after the set sAreaCode step and use a label to redirect the traffic but this throws up an exception in the script when i debug, not sure if iv implemented that correct ?

Also can you advise what the 0 is used for in the substring command you provided  CallingNumber.substring(0,3)

Thanks, Carl

Carl,

I'm glad to hear it. There should be a simple solution to your matching, instead of

if (CallingNumber == "0")

You could use:

if (CallingNumber == "" || CallingNumber == null)

This will catch bull null values and blank. Catching null is probably not necessary but it does add an additional level of testing.

I suspect you need to move the "On Exception GoTo" step up in your script, right before you call substring() in the SET step.

For substring() you pass along where you want to begin splicing characters from and where you want it to end. As such, CallingNumber.substring(0,3) is saying:

"I want the substring of CallingNumber starting at character 0 and ending at character 3 returned"

If you have the variable, CallingNumber as "3305551234", it looks like this:

CallingNumber[0] = "3"

CallingNumber[1] = "3"

CallingNumber[2] = "0"

CallingNumber[3] = "5"

CallingNumber[4] = "5"

CallingNumber[5] = "5"

CallingNumber[6] = "1"

CallingNumber[7] = "2"

CallingNumber[8] = "3"

CallingNumber[9] = "4"

Note as you might notice, CallingNumber[3] is not included. That is because according ot the definition of substring(startIndex, endIndex), startIndex is inclusive (meaning it is included in the return) and endIndex is exclusive (meaning it is not included in the return).

I hope this has helped shed some light on what is happening.

Regards,

Tanner Ezell
www.ctilogic.com

Tanner Ezell www.ctilogic.com

Thank you very much Tanner for taking time to give a great explaination and solution. Carl Ratcliffe

I prefer the .startsWith(s) method over the .substring(0, n) method.

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.

TRUE

(but not really)