I have 2 dropdowns type and courses type will be premium, free and courses for premium java, c++, and also for free also I have java , python like this . i need to display all the courses when in default and when type selected as premium it will only show that category courses. but java is in both category it displaying 2 times by default . In db they have mapped with thier unique type ids only. I tried with union but choice values and choice values length varies because of that. Can anyone help me ?
Discussion posts and replies are publicly visible
Would it be possible to create two dropdowns for courses, and show one of them depending on the type?
Are you are saying like one dropdown named courses for premium, other one is courses for free. I am not sure we can do like that.
That's the idea. Using showWhen, you can hide/display the second dropDown based on the selected type.
But what I want is to display all the unique courses by default when no type is selected.
When I read "unique" my first thought is the union() function. I'm not sure where you're dropdown values come from or how your objects are configured, but you could try something like below...
a!localVariables( local!selectedType, local!selectedCourse, local!dropdownOptionsMap: { a!map(course: "Java", type: "Premium"), a!map(course: "C++", type: "Premium"), a!map(course: "Appian", type: "Premium"), a!map(course: "Java", type: "Free"), a!map(course: "Python", type: "Free"), a!map(course: "Javascript", type: "Free"), }, local!allCourseOptions: union(local!dropdownOptionsMap.course,local!dropdownOptionsMap.course), local!courseOptions: if( a!isNotNullOrEmpty(local!selectedType), index(local!dropdownOptionsMap, wherecontains(local!selectedType, local!dropdownOptionsMap.type)).course, local!allCourseOptions ), { a!dropdownField( label: "Course Type", placeholder: "Select Course Type", choiceLabels: union(local!dropdownOptionsMap.type,local!dropdownOptionsMap.type), choiceValues: union(local!dropdownOptionsMap.type,local!dropdownOptionsMap.type), value: local!selectedType, saveInto: { local!selectedType, a!save(local!selectedCourse, null) } ), a!dropdownField( label: "Course", placeholder: "Select Course", choiceLabels: local!courseOptions, choiceValues: local!courseOptions, value: local!selectedCourse, saveInto: { local!selectedCourse, a!save( local!selectedType, if( and( a!isNotNullOrEmpty(save!value), length( index( local!dropdownOptionsMap, wherecontains( save!value, local!dropdownOptionsMap.course ) ).type ) = 1 ), index( local!dropdownOptionsMap, wherecontains( save!value, local!dropdownOptionsMap.course ) ).type, null ) ) } ) } )
The list of course options begins with all unique values in the local!dropdownOptionsMap.course. Notice Java is listed twice in local!dropdownOptionsMap.course. To get the unique list I just used union(local!dropdownOptionsMap.course, local!dropdownOptionsMap.course).
Added some logic in course selection to set the type if the selected course is unique in the list of options and logic in the type selection to clear away any previously selected course.
Hope this helps!
Will try this.Thanks.
As per my understanding on what you said. You are having a table that contains the courses like this CourseId Course Type1 Java Premium
2 Java FreeSo from this table only you are going to get the courses and displaying them in drop-down right?You are trying union on courses that is choice labels and unable to use union on choice values that is courseId.If this is the case I have some doubts
1.Why you want to show all the courses in drop-down before selecting type?
2.What you want to store as type premium or free when no type is selected and you are selecting the course?
If no type is selected and if you want to store free then you can have the choice values {2} instead of {1,2} by using wherecontains and index.
OK, so this is not about a consecutive selection, but the first dropdown is meant to filter the second.
You could use the dropDownByIndex. You store your actual records to a local variable and derive the choice labels from them. When the user makes a selection, you get the index of the selected item.
Hi iswarya2812
a!dropdownField should have unique choice values, I would suggest you to show the course type first and then showing courses based on the selected course type or else you can also use a!dropdownFieldByIndex
Refer to : https://docs.appian.com/suite/help/24.2/Dropdown_By_Index_Component.html
If both "java" entries have single, unique type IDs, does that imply that the two different "Java" offerings are actually different (as in, it sounds like there are 2 separate entries in your DB)? In that case maybe you should consider changing the label for one of them to be distinct, like "Java (premium)", etc.