Author Message
RajatVerma
Joined: Mar 5, 2014
Messages: 101
Offline
Hello All,

I am working on HTML (Visual) IVR development using OD version 7.1

I am trying to use the menu node in my script but facing below issue

1. In the main flow (AppRoot flow) I am able to drag the menu item from palette but when I am creating a subflow there I am not getting any option in palette for menu item and hence can't use it. I believe there is some bug in OD as this option should be available in sub flow as well. Also as a testing when I copied the menu item from main flow and copied in the sub flow I am able to use the same.

2. Request if you can guide me how to populate the menu items dynamically i.e. I am invoking a web service and based of its response elements I have to populate the options dynamically in the Menu. If there is any sample application available it will be help.

Thanks,
Rajat Verma
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
Your find on the missing menu item in the palette of the subflow editor seems to be a bug. We will get it fixed. Meanwhile, you can continue to use your copy-paste trick.

On creating menu items dynamically, you can take a look at the Java code in the class that corresponds to the menu you've created. In that, you can see it uses code like below in the generated getChoices method:

choice = new com.avaya.sce.runtime.html.genmodel.MenuChoiceInput("c1", "c1", "choice1", "", com.avaya.sce.runtime.html.genmodel.ChoiceInput.ChoiceType.VARIABLE, "Say1", "", "");
list.add(choice);

You can use the same coding pattern in the updateChoices method (which you have to override) to dynamically add or update the menu choices.
RajatVerma
Joined: Mar 5, 2014
Messages: 101
Offline
Hello Wilson Yu,
Thanks for your response. I tried to implement the same but couldn't achieve the desired results. Do you have any sample application for same?
I implemented below steps
Step 1 - Created a menu node in my application and added one choices as otherwise I was getting compile time error in the script. However my requirement is to load all the menu choices dynamically using one of backend API response. There will be 20-30 such dynamic choices needs to be added.
Step 2 - I overrided updateChoices method to add 2 more choices but when I ran the application I couldn't see these 2 choices added, can see only one option which was added using OD palatte in step 1.

//This was created by OD as I added one choice in my menu
public java.util.Collection getChoices(com.avaya.sce.runtimecommon.SCESession mySession) {
java.util.List list = null;
com.avaya.sce.runtime.html.genmodel.MenuChoiceInput choice = null;
java.util.Collection grammarInfo = null;
list = new java.util.ArrayList(1);
String ___tempGrammarName = null;

choice = new com.avaya.sce.runtime.html.genmodel.MenuChoiceInput("addedbyPalatte", "addedbyPalatte", "", "HTMLText:channelMenu_channel1", com.avaya.sce.runtime.html.genmodel.ChoiceInput.ChoiceType.TEXTSET, "untitledReturn1", "", "");
list.add(choice);

return(list);
}

//This was added by me for adding dynamic choices
@Override
public void updateChoices(Collection choices, SCESession mySession) {

//java.util.List list = null;
com.avaya.sce.runtime.html.genmodel.MenuChoiceInput choice = null;
java.util.Collection grammarInfo = null;
//list = new java.util.ArrayList(2);
String ___tempGrammarName = null;

choice = new com.avaya.sce.runtime.html.genmodel.MenuChoiceInput("dynamic1", "dynamic1", "", "HTMLText:channelMenu_channel1", com.avaya.sce.runtime.html.genmodel.ChoiceInput.ChoiceType.TEXTSET, "untitledReturn1", "css/images/user.png", "");

choices.add(choice);

choice = new com.avaya.sce.runtime.html.genmodel.MenuChoiceInput("dynamic2", "dynamic2", "", "HTMLText:channelMenu_channel2", com.avaya.sce.runtime.html.genmodel.ChoiceInput.ChoiceType.TEXTSET, "untitledReturn1", "http://localhost:8080/images/user.png", "");
choices.add(choice);



}
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
Actually there is one more step you need to do. The default menu node jsp does not work with the code you added. You need to generate a customized version of the jsp by doing the following:

1. Right-click on the menu node and select Customize... in the context menu.
2. Right-click on the project and select Orchestration Designer->Generate Project in the context menu

That should give you a different version of the jsp file that works with the Java code you added.

If you encounter any problem, the Dev_Guide doc has more information on customizing nodes for web projects.
RajatVerma
Joined: Mar 5, 2014
Messages: 101
Offline
Hello Wilson,

I performed the additional steps suggested by you as well.
1. Right-click on the menu node and select Customize... in the context menu. - I can see an additional file under custom folder with name DynamicMenu_template.jsp. DynamicMenu is the name of my menu which I created for populating with dynamic choise
2. Right-click on the project and select Orchestration Designer->Generate Project in the context menu - DONE

Still options are not loading dynamically, I also suspect that updateChoices method is not executing at all as for testing purpose I have given SOP there but that's also not getting printed over console.

Thanks,
Rajat Verma
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
It turns out the updateChoices wasn't supported for web project until 7.2.0. You need to upgrade.
RajatVerma
Joined: Mar 5, 2014
Messages: 101
Offline
Hello Wilson,

AAEP installed is 7.1.0, will HTML IVR developed on OD 7.2.x With Dynamic Menu) be compatible with AAEP 7.1.0?
or can you share me any patch for AAOD 7.1.0

Thanks,
Rajat Verma
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
Yes, they are compatible. You can just upgrade OD.
RajatVerma
Joined: Mar 5, 2014
Messages: 101
Offline
Thanks Wilson!
I have tried with upgraded version of OD and able to populate with dynamic choices.
Any suggestion on how to remove or override the default choice which I had to add as without it I can’t create a menu.
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
You can just use a simple Java call to clean the collection first in the updateChoices method.

choices.removeAll(choices);
RajatVerma
Joined: Mar 5, 2014
Messages: 101
Offline
Hello,
Need one more help regarding populating the menu value and name while populating the dynamic values from the backend response.
I am able to find 2 ways i.e. populating the values referring to values already defined in text set, however I can't use the same as I have to populate the values based on backend API response.

//This I can't use
choice = new com.avaya.sce.runtime.html.genmodel.MenuChoiceInput("dynamic2", "dynamic2", "", "HTMLText:channelMenu_channel4", com.avaya.sce.runtime.html.genmodel.ChoiceInput.ChoiceType.TEXTSET, "untitledReturn1", "http://localhost:8080/images/user.png", "");
choices.add(choice);

Other alternative I tried to use was populating the values using variable, but in that case I can't make use of single defined variable as it keeps on overridden by last value. For example I have to populate 2 dynamic menu options. I created one test1 var as simple variable in application and used below code

mySession.getVariableField(IProjectVariables.TEST_1).setValue("Channel5");

choice = new com.avaya.sce.runtime.html.genmodel.MenuChoiceInput("dynamic3", "dynamic3", "test1", "", com.avaya.sce.runtime.html.genmodel.ChoiceInput.ChoiceType.VARIABLE, "untitledReturn1", "http://localhost:8080/images/user.png", "");
choices.add(choice);

mySession.getVariableField(IProjectVariables.TEST_1).setValue("Channel6");

choice = new com.avaya.sce.runtime.html.genmodel.MenuChoiceInput("dynamic3", "dynamic3", "test1", "", com.avaya.sce.runtime.html.genmodel.ChoiceInput.ChoiceType.VARIABLE, "untitledReturn1", "http://localhost:8080/images/user.png", "");
choices.add(choice);

In this case 2 dynamic menu options are created but both shows me the same value i.e. channel6 i.e. the last value specified for variable.

Is there any way I can simply specify some text values based on backend API response? Kindly advice.

WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
The problem with the variable is it is accessed when the page is being rendered. It won't work for your case. So you only option left is to make a change to the Menu template jsp code. From the previous discussion, you should already have a customizable copy of the menu jsp file, named with the node name and "_template.jsp" in the custom directory. What you need to do is editing the part (below) using your programming skill:

for (MenuChoiceInput choice : choices) {
String choiceName = (choice.getChoiceType() == ChoiceInput.ChoiceType.TEXTSET?choice.getChoicesTextset():choice.getChoicesVariable());
String next = choice.getNext();
String icon = choice.getIcon();
String descName = choice.getDescription();
String nameId = choice.getName();

name = (MenuChoiceInput.getChoice(choiceName,choice.getChoiceType(), mySession));
desc = (MenuChoiceInput.getDescriptionTextset(descName, mySession));

This logic mainly loops through the collection you built in the sevlet and get each menu option's name, icon and desc. You can modify it to work with the data you get.
RajatVerma
Joined: Mar 5, 2014
Messages: 101
Offline
Thanks Wilson, This is working.
RajatVerma
Joined: Mar 5, 2014
Messages: 101
Offline
Hello Wilson,

I tried to read the value of dynamic Menu option selected by caller in next data node using "menuName:value" but getting error/exception here to get the value. I seem this is because I have populated the options dynamically.

MenuName is the name of node I have kept in OD

//below is MenuName.java class where I used to populate the dynamic menu options using updateChoice function
choice = new com.avaya.sce.runtime.html.genmodel.MenuChoiceInput(genreTypeString, genreTypeString, "dynamicChannelGenreType", "", com.avaya.sce.runtime.html.genmodel.ChoiceInput.ChoiceType.VARIABLE, "GetDtvChannelList-srv_setMenuValue", "/css/images/hbo.jpg", "");
choices.add(choice);


In the MenuName_template.jsp (Customized jsp) I have written custom java code to just change the name and icon of my menu options based on backend API response. This is written where loop is executed for all choices defined.

Kindly advice.
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
I don't know what exactly causes the error. If you look inside the menu jsp file, the line

<a href="<%=choice.getNext()%>?<%=SCERT.DDSESSIONID%>=<%=mySession.getEncodedSessionId()%>&<%=menuVarName%>___value=<%=nameId%>">

is what comes down to. It is passing back the value of nameId using the <menu name>___value parameter in the URL. That's what will be stored in the menu variable's value field.
Go to:   
Mobile view