UCCX Scripting

Answered Question
Jan 15th, 2010
User Badges:

I have a question, i'm in the middle of programming a scripting and just realized that i need to create a nested if step.


Do you know what's the maximum if's that can be nested? I need to nest 25 ifs on my script

or if you could recommend a better way to do it I'd appreciated it


this is what i need to do pretty much on this step


based on the CalledNumber I need to set a fixed password to a variable. do you know a way to do this besides the nested ifs ?

Correct Answer by Tanner Ezell about 7 years 3 months ago

Cris,


Try this:


String[] stringContainer

int counter

/* I'm going to assume you know how to read from an XML Document, if not I can help you */

/* create a loop to run through getting lines from the XML file */

Loop Start:

xmlString = Get XML Document Data ("/descendant::Passwords/child::Password" + counter)

if(xmlString != null)

     True:

         stringContainer = xmlString.split(";")

          if (stringContainer[0] == )

               True:

                    /* set your password, password will be in stringContainer[1] */

                    /* do whatever then break the loop */

               False:

                    Increment Counter

                    Goto Loop Start


In your XML document, format it as such (names are irrelevant)



     5000;cisco

     5001;c1sco



The format is simple: CalledNumber;Password


The script will run through the file testing stringContainer[0] (the called number) against whatever variable you have stored the called number in. If it finds it, the password will be in stringContainer[1]


Let me know of any questions.

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 5 (1 ratings)
Loading.
Correct Answer
Tanner Ezell Fri, 01/15/2010 - 11:37
User Badges:
  • Silver, 250 points or more

Cris,


Try this:


String[] stringContainer

int counter

/* I'm going to assume you know how to read from an XML Document, if not I can help you */

/* create a loop to run through getting lines from the XML file */

Loop Start:

xmlString = Get XML Document Data ("/descendant::Passwords/child::Password" + counter)

if(xmlString != null)

     True:

         stringContainer = xmlString.split(";")

          if (stringContainer[0] == )

               True:

                    /* set your password, password will be in stringContainer[1] */

                    /* do whatever then break the loop */

               False:

                    Increment Counter

                    Goto Loop Start


In your XML document, format it as such (names are irrelevant)



     5000;cisco

     5001;c1sco



The format is simple: CalledNumber;Password


The script will run through the file testing stringContainer[0] (the called number) against whatever variable you have stored the called number in. If it finds it, the password will be in stringContainer[1]


Let me know of any questions.

Tanner Ezell Fri, 01/15/2010 - 11:40
User Badges:
  • Silver, 250 points or more

To answer your original question,


No, there is no limit to how many nested ifs (or anything for that matter) there are. The only limit is based on how many Steps will be executed per step.

Jonathan Schulenberg Fri, 01/15/2010 - 13:30
User Badges:
  • Super Bronze, 10000 points or more
  • Cisco Designated VIP,

    2017 IP Telephony

I have nothing against using an XML source document (although that is a unique way of formatting the data in XML); however, you can also just use a Switch step. This would collapse all of your If steps into a single level.

Tanner Ezell Fri, 01/15/2010 - 13:37
User Badges:
  • Silver, 250 points or more

Using the XML file has the advantage of allowing you to modify it without having to reload the application and script.


You could probably argue that from a maintenance stand point that the XML file is easier to manage (for those who are perhaps not comfortable with scripting, for instance).


Of course there is the downfall that if someone goes mucking around and deletes the XML file, you're screwed

Actions

This Discussion