CRS Scripting advice

Answered Question
Apr 14th, 2010
User Badges:

A couple of days ago two gentlemen in these forums helped me work out a scritping problem.  I want to learn more about scripting expressions but would like some advice.  I'm working through the Scripting and Development Series volumes (which can be daunting to someone who doesn't do any programming) to reverse engineer syntax that was suggested to me.


I want to know why this syntax works.


My original problem was that I wanted to take a 5 digit extension coming into the call center, keep the last 4 digits and replace the first one with a "3".  This line, combined with the appropriate variable and placed in a "set" step does the trick;


"3" + DNIS.substring(DNIS.length() - 4)


So, knowing what I do about the problem, I understand what this does.  A "3" +  at the start of this syntax means that the character will be prepended to the final output.  Fair enough.  There are two modifiers that I would like to learn more about.  The ".length" modifier is described on page 95 of volume 3.  While .substring makes intuitive sense, I can't seem to find it in the documentation.  How would l otherwise know that this syntax is available?


In parenths, the syntax is telling us that the DNIS variable's length will be "- 4".  Two questions - 1) Is this necessarily always going to be right-justified?  What if I wanted to keep the first 4 instead of the last 4, how would that look?  Also, what do the "()" characters do?  Where can I turn to find an explanation?


Or, am I missing the boat completely and this syntax was put together with the drop-downs?


Confusing.

Correct Answer by Jonathan Schulenberg about 7 years 1 month ago

All of these are simple Java methods so most public Java 1.4.2 documentation will work. The most valuable addition would be some basic programming knowledge as Java is just another language. The CCX Editor is just absracting some of the Java beans code through drag-and-drop steps for you.


The String substring method allows you to choose a start and stop position as well. In the example you were given it was right-justified only because the start position defined was the last position of the variable value. This could as easily be DNIS.substring(0, 2) to copy the first three characters.

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 5 (1 ratings)
Loading.
Correct Answer
Jonathan Schulenberg Wed, 04/14/2010 - 10:40
User Badges:
  • Super Bronze, 10000 points or more
  • Cisco Designated VIP,

    2017 IP Telephony

All of these are simple Java methods so most public Java 1.4.2 documentation will work. The most valuable addition would be some basic programming knowledge as Java is just another language. The CCX Editor is just absracting some of the Java beans code through drag-and-drop steps for you.


The String substring method allows you to choose a start and stop position as well. In the example you were given it was right-justified only because the start position defined was the last position of the variable value. This could as easily be DNIS.substring(0, 2) to copy the first three characters.

shikamarunara Wed, 04/14/2010 - 10:50
User Badges:

Jonathan,

     Can I count on all of the strings listed in the Java documentation to work with the CRS editor?  I just want to know what to read to get caught up.  Are there exceptions?

Jonathan Schulenberg Wed, 04/14/2010 - 11:29
User Badges:
  • Super Bronze, 10000 points or more
  • Cisco Designated VIP,

    2017 IP Telephony

Generally speaking yes. There are security measures in place starting in 8.0 to protect the appliance model (i.e. the classes that result in disk I/O will throw an exception). I would imagine any expression-related method or class should work.

shikamarunara Wed, 04/14/2010 - 11:49
User Badges:

Thank you, Jonathan.  This is a good start for me.  Much appreciated.

Anthony Holloway Wed, 04/14/2010 - 18:41
User Badges:
  • Purple, 4500 points or more

I wrote up what I thought was a nice explanation with fancy colors and everything.  But then the forum software messed it up and made it useless.  Just go with what Jon said.  Sorry.


Message was edited by: Anthony Holloway - This new forum is buggy

Actions

This Discussion