cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
4466
Views
0
Helpful
9
Replies

UCCX Script String Substring Function

I cannot use the Substring function to obtain a specific value from a string variable.

My substring position is variable, so I need to put a variable, loop and increment it the position.

When I try to add the below command, this is getting the error message:

Command: set STR_Resultado = STR_Valor.substring(P1,2+1)

Error message:

"Unable to parse expression; error while parsing string: STR_Valor.substring(P1,P2); nested exception is java.lang.NullPointerException"

9 Replies 9

Jonathan Schulenberg
Hall of Fame
Hall of Fame
  • To ask the obvious: do either P1 or STR_Valor have a null value at the time that step executes? If they do, this is the expected result. Use an On Exception Goto step or other preventative code to protect the step from this exception.
  • Why does your command and the error not match?
    • Command: substring(P1,2+1)
    • Exception: substring(P1,P2)
  • If the command statement is what you're actually using (your image attachment isn't showing) then I believe you have a syntax error. The substring method documentation doesn't suggest you can do additive operations here.

Most likely the first bullet though...

PS- You may want to get the length of the string first and ensure that the startIndex and endIndex are less than or equal to it. I believe you'll get a IndexOutOfBoundsException if you try to pull a substring from outside the bounds of the actual string.

Please remember to rate helpful responses and identify helpful or correct answers.

Hi Jonathan, how are doing?

Which exception I will choose for this case?

Thank you

I am going to guess one of two things is happening, but keep in mind, none of us have seen your script yet.

  1. The editor just plain messes up sometimes and when you click Apply or Ok on property dialogs, it sometimes reports that there is an error when there really is not.  To get around this when it happens I usually do one of two things:
    1. I keep clicking Apply or Ok until it takes the value (yes, I know how silly that sounds, but trust me, it happens)
    2. I back out my changes with the cancel button and then try again.
  2. Your script is corrupt.  To test this, create a new script from File > New and then only create four variables: String STR_Valor = "abcd", String STR_Resultado = "", int start = 0, and int end = 2.  Then place a single set step into the script and set STR_Resultado  = STR_Valor.substring(start, end) and see if it lets you click Apply and OK.  If it does, then follow that up with an Active Debug sessions by pressing the Step Over button in the tool bar.

And as a remote possibility: you are using UCCX Standard, but I think the step would still be allowed during design mode, you just wouldn't be able to run the script.

Anthony Holloway

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

Hi Anthony,

I'm using a Premiun license, so I'm able to use all Java commands.

Please take a look on attached script.

Worked for me. I even Active Debugged it all the way through the string as seen below.

uccx-substring.png

Try a different computer+editor?  Reinstall the one you're using?  Are you using a supported OS for the editor?

Compatibility guide:

http://www.cisco.com/c/dam/en/us/td/docs/voice_ip_comm/cust_contact/contact_center/crs/express_compatibility/matrix/crscomtx.pdf

Anthony Holloway

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

I have tried from another PC and got the same problem. I also reinstalled the application on my PC and doesn't work.

Error message:

"Unable to parse expression; error while  parsing string: STR_Valor.substring(P1,P2); nested exception is  java.lang.NullPointerException"

Jefferson, can you please post a screenshot of that script while doing reactive debugging. I just want to take a look at the actual values of the STR_Valor, P1 and P2 variables, if this is possible.

Thanks.

G.

I thought the same thing too, but this is what he said:

When I try to add the below command...

Which to me, means that he's trying to configure the script and not even able to run it.  But good question though, because he may have just chose the wrong words.

Anthony Holloway

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

Gergely Szabo
VIP Alumni
VIP Alumni

Hi, oh, silly me. Now I see.

Jefferson, can you please post the window of that Set step when trying to add the above expression?

G.


Sent from Cisco Technical Support Android App

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: