Expand my Community achievements bar.

SOLVED

Populate drop down value depending on previous drop down selection

Avatar

Level 3

I have a requirement to populate a drop down depending on a value chosen from a previous drop down list in an Input form.

Let's say there are 2 drop downs - product group and sport name in the nms:operation table.

I have created 4 enumerations in the data schema: 

Product group= A, B, C.

sport Name A = A1. A2, A3

Sport Name B= B1, B2, B3

Sport Name C= C1, C2, C3

Depending on what is selected in product group, the sport name field should be populated with the relevant enum values.

If product group is A - I should get A1, A2 and A3 in the sport name drop down list.

If product group is B - I should get B1, B2 and B3 in the sport name drop down list.

If product group is C - I should get C1, C2 and C3 in the sport name drop down list.

In the nms:operation Input form I used the below code:

 
 

<container label="Reporting" name="cusReporting">
<container type="notebook">
<container colspan="2" label="General">
<container colcount="2" label="General" type="frame">
<input xpath="@productGroup"/>

<container visibleIf="@productGroup='A'" type="visibleGroup">
<input enum="sportNameA" type="sysenum" xpath="@sportName"/>
</container>

<container visibleIf="@productGroup='B'" type="visibleGroup">
<input enum="sportNameB" type="sysenum" xpath="@sportName"/>
</container>

<container visibleIf="@productGroup='C'" type="visibleGroup">
<input enum="sportNameC" type="sysenum" xpath="@sportName"/>
</container>

</container>
</container>
</container>
</container>

 

With this, I am able to populate the sportName enum values correctly in drop down for example when I select product group = 'A' , I see A1, A2 , A3 in sport name drop down. but when I select a different value in product group for ex. 'B' it gives the following error:

Value 'A2' is not valid for enumeration 'sportNameB (nms:operation:sportNameB)'.

I also tried using "If" expression in the form but unable to get rid of the error.

Can someone advise?

@Amit_Kumar 

@Vipul_Raghav 

@pablo_rosero1 

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

 

Instead of using 'onClick' use 'onChange' function.

 

Use below code, it should work:

<input choiceButton="true" xpath="@productGroup">
<enter name="onChange">
<set value="0" xpath="@sportName"/>
<reset xpath="@sportName"/>
</enter>
</input>

 

Also, in your schema definition, you are defining product as attribute, revCardinality and integrity is not required. Those parameters are used when you define element.

 

Thanks.

View solution in original post

7 Replies

Avatar

Community Advisor

Hello @ishanishah,

 

Apart from this you will have to use other form command like If,set and enter.

You can refer to this article to know more about how this will work.
https://blog.floriancourgey.com/2018/09/adobe-campaign-input-form-helper/

Thanks


     Manoj
     Find me on LinkedIn

Avatar

Community Advisor

Can you please share the xml code for Enums you created at schema level. 

Avatar

Level 3

I used the below code in the input form:

 

<container colcount="2" label="General" type="frame">
<input choiceButton="true" xpath="@productGroup">
<enter name="onClick">
<set value="0" xpath="@sportName"/>
<reset xpath="@sportName"/>
</enter>
</input>
<container type="visibleGroup" visibleIf="@productGroup='A'">
<input enum="sportNameA" type="sysenum" xpath="@sportName"/>
</container>

<container type="visibleGroup" visibleIf="@productGroup='B'">
<input enum="sportNameB" type="sysenum" xpath="@sportName"/>
</container>

<container type="visibleGroup" visibleIf="@productGroup='C'">
<input enum="sportNameC" type="sysenum" xpath="@sportName"/>
</container>
</container>

 

Can you suggest another way of setting the value? The enums don't get set.

 

The data schema is below:

<enumeration basetype="string" default="none" name="cusProductGroup">
<value label="None" name="none"/>
<value label="A" name="a" value="A"/>
<value label="B" name="b" value="B"/>
<value label="C" name="c" value="C"/>
</enumeration>

<enumeration basetype="string" default="none" name="sportNameA">
<value label="None" name="none" value="0"/>
<value label="A1" name="a1" value="A1"/>
<value label="A2" name="a2" value="A2"/>
<value label="A3" name="a3" value="A3"/>
</enumeration>

<enumeration basetype="string" default="none" name="sportNameB">
<value label="None" name="none" value="0"/>
<value label="B1" name="b1" value="B1"/>
<value label="B2" name="b2" value="B2"/>
<value label="B3" name="b3" value="B3"/>
</enumeration>

<enumeration basetype="string" default="none" name="sportNameC">
<value label="None" name="none" value="0"/>
<value label="C1" name="c1" value="C1"/>
<value label="C2" name="c2" value="C2"/>
<value label="C3" name="c3" value="C3"/>
</enumeration>


<element img="nms:operation.png" label="Campaigns" labelSingular="Campaign" name="operation">

<attribute enum="cusProductGroup" label="Product Group" length="30" name="productGroup"
revCardinality="single" revIntegrity="normal" type="string"/>
<attribute label="Sport Name" length="30" name="sportName" type="string"/>

</element>

Avatar

Level 4

That error / warning as per design Value 'A2' is not valid for enumeration 'sportNameB (nms:operation:sportNameB)'.. 

This is because A1, A2 , A3 values were valid for Product A but for product B its not valid . 

 

 

Solution is Clear the value A1, A2, A3 forcefully and populate this field everytime when Product A or B is selected. 

make it onclick event and it should work after that. 

Avatar

Level 3

Hi Prasanna,

 

I tried setting the value below but this is not wokring for enumerations:

 

<container colcount="2" label="General" type="frame">
<input choiceButton="true" xpath="@productGroup">
<enter name="onClick">
<set value="0" xpath="@sportName"/>
<reset xpath="@sportName"/>
</enter>
</input>
<container type="visibleGroup" visibleIf="@productGroup='A'">
<input enum="sportNameA" type="sysenum" xpath="@sportName"/>
</container>

<container type="visibleGroup" visibleIf="@productGroup='B'">
<input enum="sportNameB" type="sysenum" xpath="@sportName"/>
</container>

<container type="visibleGroup" visibleIf="@productGroup='C'">
<input enum="sportNameC" type="sysenum" xpath="@sportName"/>
</container>
</container>

 

Is there another way to do this?

Avatar

Correct answer by
Community Advisor

Hi,

 

Instead of using 'onClick' use 'onChange' function.

 

Use below code, it should work:

<input choiceButton="true" xpath="@productGroup">
<enter name="onChange">
<set value="0" xpath="@sportName"/>
<reset xpath="@sportName"/>
</enter>
</input>

 

Also, in your schema definition, you are defining product as attribute, revCardinality and integrity is not required. Those parameters are used when you define element.

 

Thanks.