05-31-2016 08:42 AM - edited 03-14-2019 04:10 PM
All,
This is probably a silly question, but I am trying to achieve the following. I have a script that has a menu step that is Identical for 2 different Triggers. Depending on the Trigger however, we have different numbers that they do a call redirect to. Each option is for a different campus of our institution. The two campuses are RUMC and ROPH. I have string variables for each menu option 1-9 that are named sMainOptionxROPH and sMainOptionxRUMC. At the beginning of my script I have a Switch with cases for each campus. I have a Switch, because there are more options, but irrelevant for my explanation. On the switch I set the variable sHospCalled to either RUMC or ROPH. In my menu, I need to set the value of the string variable sRedirectNumber to the value of "sMainOption1"+"sHospCalled". The problem is that I need the actual value of the variable for example if sMainOption1ROPH is "65555" I need that value, not the literal string "sMainOption1sHospCalled".Help is greatly appreciated. this goes live tomorrow.
Solved! Go to Solution.
05-31-2016 12:00 PM
Please post your script and specify what the final value of your redirect extension needs to be. I think you are trying to over complicate things here, so these 2 items will clear it up.
05-31-2016 09:23 AM
So, you would have a generic variable call it sRedirectNumber which under each switch option is statically set to a value i.e. "65555" under node1, and "6555X" under node 2. The in the common logic where it's used you simply invoke it. Let's assume that this is an extension you perform redirect to you would have Redirect to string variable sRedirectNumber.
05-31-2016 11:13 AM
Chris,
Thank you for your prompt answer. Let me rephrase my question. I want to interpret the values of a string variable as a variable of themselves. for example, I have the following Variables
sHospCalled == "" (Value is dependent of trigger that invokes the script)
sMainOption1ROPH == "25555"
sMainOption1RUMC == "65555"
I want to dynamically set the value of my sRedirectNumber String Variable. So, I concatinate "sMainOption1"+"sHospCalled". This results in the string of either sMainOption1ROPH or sMainOption1RUMC. As I stated before, that is a variable, but it gets interpreted as the string itself, not the variable value of either "25555" or "65555". To summarize, I would like to interpret the contents of a String variable as a variable and not to the string.
05-31-2016 11:32 AM
What is the purpose of concatenating "sMainOption1"+"sHospCalled"?
What should be the outcome of this concatenation? Is it either 25555 or 65555 or something else? Can you post your current script?
05-31-2016 11:57 AM
Because I want the script to be dynamic an yet minimize my code. So i have sMainOption1-9 and two options for RUMC or ROPH. So I have a total of 18 variables. As a reminder, these are variables for each of my branches of my Menu Step. Each variable contains the string containing the Directory Number that will be used for the call redirect step based on user selection. If a user Calls RUMC, my switch sets the variable sHospCalled to "RUMC" then the goTo sends the call to a menu step. If the user presses 4 then, i set the variable sRedirectNumber to "sMainOption4"+sHospCalled. This results in a string "sMainOption4RUMC". But, remember that I have 18 variables sMainOptionxRUMC(ROPH). Each variable contains a DN. I want that value to be assigned to sRedirectNumber and not the string "sMainOption4RUMC". I tried uploading the script, but file type is not supported.
05-31-2016 12:00 PM
Please post your script and specify what the final value of your redirect extension needs to be. I think you are trying to over complicate things here, so these 2 items will clear it up.
05-31-2016 12:31 PM
05-31-2016 02:22 PM
The step "set sHospCalled = "ROPH" will set this variable to string ROPH, what is this suppose to be? As I don't think you want to to be this text, yet if you want sHospCalled to be the value of another variable you can use sHospCalled = variableName (without quotes), but I don't see variable ROPH defined.
The I see sRedirectNumber = "sMainOption1"+ sHospCalled, again you are concatenating text (stuff in quotes) with value of a variable which at this time might be ROPH and you end up with "sMainOption1ROPH".
If the goal is to create a value based on 2 inputs, where first is based on the called number and the second is based on caller input during the menu, then do this:
under each switch node set sHospCalled = var1 (use the desired variable name without quotes)
and next under menu nodes set sRedirectingNumber = var2 + var1 (again no quotes).
05-31-2016 03:20 PM
Thank you for your patience and cooperation Chris.
The step "set sHospCalled = "ROPH" will set this variable to string ROPH, what is this suppose to be? As I don't think you want to to be this text, yet if you want sHospCalled to be the value of another variable you can use sHospCalled = variableName (without quotes), but I don't see variable ROPH defined.
sHospCalled is a variable that identifies which campus was called. BUT The important thing here is that I have string variables for the mainMenu that either end in ROPH or RUMC.
The I see sRedirectNumber = "sMainOption1"+ sHospCalled, again you are concatenating text (stuff in quotes) with value of a variable which at this time might be ROPH and you end up with "sMainOption1ROPH".
the result of the concatenation of the string "sMainOption1" and the variable sHospCalled should result in something like "sMainOption1ROPH". BUT sMainOption1ROPH is a variable. I want the value of sRedirectNumber to be assigned the value of sMainOption1ROPH. I do not want sRedirectNumber to be assigned the string "sMainOption1ROPH".
If the goal is to create a value based on 2 inputs, where first is based on the called number and the second is based on caller input during the menu, then do this:
under each switch node set sHospCalled = var1 (use the desired variable name without quotes)
and next under menu nodes set sRedirectingNumber = var2 + var1 (again no quotes).
05-31-2016 04:15 PM
java script version of my issue:
http://stackoverflow.com/questions/5613834/convert-string-to-variable-name-in-javascript
07-25-2016 12:20 PM
Adan - Did you ever get this to work? I've got a very similar issue. I'm creating a script where callers can select an option and be redirected to a particular cell phone based on their selection. I'd like to keep all the cell numbers in variables for easy maintenance.
Variables:
cell_userA = 1111
cell_userB = 2222
---
Switch:
Option 1 - Set usertemp = "userA"
Option 2 - Set usertemp = "userB"
---
Set dialstring = "cell_" + usertemp
---
The desired behavior is that if the caller chooses Option 1, the usertemp variable will be set to "userA" and then the dialstring will be set to "1111".
07-26-2016 12:39 PM
Unfortunately I did not! I see how in both cases this would be very beneficial. If I find out, I will let you know. As well as if you find a solution, kindly let me know please.
10-24-2018 08:42 AM
Hello.
I'm looking for same solution. Maybe you found it?
10-25-2018 12:06 PM
10-26-2018 02:31 AM - edited 10-26-2018 02:34 AM
Hi all.
I found a solution for this task. I have 17 triggers attached to one application. I use set step.
Set TriggerIndex = {java.util.HashMap map = new java.util.HashMap(); map.put("Trigger1", Trigger1); map.put("Trigger2", Trigger2); return map.get("Trigger"+x); }
"Trigger1" - set name of variable
Trigger1 - get value of variable
Script attached.
I have a question. Is my script useful or not? If I want to use less system resources, maybe I need to use 17 times "If"?
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide