Expand my Community achievements bar.

Announcing the launch of new sub-community for Campaign Web UI to cater specifically to the needs of Campaign Web UI users!
SOLVED

Populating drop-down value depending on previous drop down selection

Avatar

Level 7

Hello All,

We have a requirement to populate a drop-down values based on value selected in the previous drop-down. I have 2 fields Category and Product both are drop-downs. Based on category selected the corresponding products should be shown. For this I have a Mapping table created in following way:

CategoryProduct NameProduct Code
SportsCricketCR
 HockeyHO
 FootballFB
BooksBook1B1
 Book2B2
 Book3B3

I was referring to this Input Form documentation and tried establishing a unbound link (Collection) and using it as x-path in Form. However, I was not able to get the expected result.

 

Kindly need your help (if possible with an example) on how can I achieve this.

@Adhiyan , @Vipul_Raghav , @Amit_Kumar 

 

Thanks,

SSB

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hello @Ssb_94 

 

I believe you were trying to create an input form in the campaign.

 

You might have to change the data schema a little bit.

 

Here is the code for Dataschema

<srcSchema _cs="products (cus)" created="2021-09-23 02:21:35.877Z" createdBy-id="0"
           entitySchema="xtk:srcSchema" img="xtk:schema.png" label="products" lastModified="2021-09-23 02:28:27.038Z"
           mappingType="sql" md5="B97497674F60132FBAFCAC006EBC872F" modifiedBy-id="0"
           name="products" namespace="cus" xtkschema="xtk:srcSchema">

  <enumeration basetype="string" default="none" name="productCategory">
    <value label="None" name="none" value="0"/>
    <value label="sports" name="sports" value="sports"/>
    <value label="books" name="books" value="books"/>

  </enumeration>

  <enumeration basetype="string" default="none" name="productSports">
    <value label="None" name="none" value="0"/>
    <value label="cricket" name="cricket" value="cricket"/>
    <value label="hockey" name="hockey" value="hockey"/>
    <value label="football" name="football" value="football"/>
  </enumeration>

  <enumeration basetype="string" default="none" name="productBooks">
    <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>

  <element autopk="true" label="products" name="products">

    <attribute enum="productCategory" label="Product Category" length="30" name="productCategory"
               type="string"/>
    <attribute label="Product Name" length="30" name="productName" type="string"/>
  </element>
</srcSchema>

 

Here is the code for Input form:

<form _cs="products (cus)" created="2021-09-23 02:29:05.211Z" createdBy-id="0" entitySchema="xtk:form"
      img="xtk:form.png" label="products" lastModified="2021-09-23 02:36:52.748Z"
      md5="F44C7E157333DD53B1437FEA50580649" modifiedBy-id="0" name="products" namespace="cus"
      xtkschema="xtk:form">
  <container codepage="1252" colcount="2" label="General" type="frame">
    <input choiceButton="true" xpath="@productCategory">
      <enter name="onChange">
        <set value="0" xpath="@productName"/>
        <reset xpath="@productName"/>
      </enter>
    </input>
    <container codepage="1252" type="visibleGroup" visibleIf="@productCategory='sports'">
      <input enum="productSports" type="sysenum" xpath="@productName"/>
    </container>
    <container codepage="1252" type="visibleGroup" visibleIf="@productCategory='books'">
      <input enum="productBooks" type="sysenum" xpath="@productName"/>
    </container>
  </container>
</form>

 

Here is the preview of the options how they will appear in the form

Manoj_Kumar__0-1632364794156.png

 

Manoj_Kumar__1-1632364819330.png

 

 

Let me know if this worked for you.


     Manoj
     Find me on LinkedIn

View solution in original post

9 Replies

Avatar

Employee

Hello SSB,

 

You can probably achieve this with a web form / web App's combo box feature with visibility conditions.

 

For example -

1 >. Create a variable and assign categories Sports and Book. Type of input should be combo box.

 

Adhiyan_0-1632238903188.png

 

 

2>. Then create another combo box with Product name and add the values for sports

In this input select the visibility condition as var1 = Sports

example -

Adhiyan_1-1632239070288.png

 

3. Similarly create another combo box input for Books and add a visibility condition var1 = Books.

 

End result should be a web form allowing you to choose as per dropdown inputs

Books

Adhiyan_2-1632239318730.png

Sports

Adhiyan_3-1632239354377.png

PS - you can try the combo box approach on input Forms as well but then you would have to define  enumerations for Category , Product names and Books to ensure they are available in the dropdown menus.

 

Regards,

Adhiyan

Avatar

Level 7

Thanks @Adhiyan ,

We used enumerations for drop-downs. However, we can't able to restrict like "when a value of first drop-down is chosen, second drop-down values should change based on chosen value of first drop-down.

Any inputs revolving it would be helpful

Avatar

Level 1

Hi,

 

You should be able to restrict enumerations by editing the visibility conditions and filtering based on values of the enums.

example - You can choose the category and then in the sports enumeration , add a visibility condition so that sports is only visible when category is sports

 

chattopa_0-1633007894934.png

 

In this example , the Error reason dropdown will only be visible if the status is 4

 

 

Regards,

Adhiyan

 

Avatar

Level 7

Thank you @Adhiyan  and @chattopa ,

We were able to do it using Input Forms. Right now we are not having any requirement of implementing WebApp. If we do so i future, will use this solution for combo-boxes

Avatar

Correct answer by
Community Advisor

Hello @Ssb_94 

 

I believe you were trying to create an input form in the campaign.

 

You might have to change the data schema a little bit.

 

Here is the code for Dataschema

<srcSchema _cs="products (cus)" created="2021-09-23 02:21:35.877Z" createdBy-id="0"
           entitySchema="xtk:srcSchema" img="xtk:schema.png" label="products" lastModified="2021-09-23 02:28:27.038Z"
           mappingType="sql" md5="B97497674F60132FBAFCAC006EBC872F" modifiedBy-id="0"
           name="products" namespace="cus" xtkschema="xtk:srcSchema">

  <enumeration basetype="string" default="none" name="productCategory">
    <value label="None" name="none" value="0"/>
    <value label="sports" name="sports" value="sports"/>
    <value label="books" name="books" value="books"/>

  </enumeration>

  <enumeration basetype="string" default="none" name="productSports">
    <value label="None" name="none" value="0"/>
    <value label="cricket" name="cricket" value="cricket"/>
    <value label="hockey" name="hockey" value="hockey"/>
    <value label="football" name="football" value="football"/>
  </enumeration>

  <enumeration basetype="string" default="none" name="productBooks">
    <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>

  <element autopk="true" label="products" name="products">

    <attribute enum="productCategory" label="Product Category" length="30" name="productCategory"
               type="string"/>
    <attribute label="Product Name" length="30" name="productName" type="string"/>
  </element>
</srcSchema>

 

Here is the code for Input form:

<form _cs="products (cus)" created="2021-09-23 02:29:05.211Z" createdBy-id="0" entitySchema="xtk:form"
      img="xtk:form.png" label="products" lastModified="2021-09-23 02:36:52.748Z"
      md5="F44C7E157333DD53B1437FEA50580649" modifiedBy-id="0" name="products" namespace="cus"
      xtkschema="xtk:form">
  <container codepage="1252" colcount="2" label="General" type="frame">
    <input choiceButton="true" xpath="@productCategory">
      <enter name="onChange">
        <set value="0" xpath="@productName"/>
        <reset xpath="@productName"/>
      </enter>
    </input>
    <container codepage="1252" type="visibleGroup" visibleIf="@productCategory='sports'">
      <input enum="productSports" type="sysenum" xpath="@productName"/>
    </container>
    <container codepage="1252" type="visibleGroup" visibleIf="@productCategory='books'">
      <input enum="productBooks" type="sysenum" xpath="@productName"/>
    </container>
  </container>
</form>

 

Here is the preview of the options how they will appear in the form

Manoj_Kumar__0-1632364794156.png

 

Manoj_Kumar__1-1632364819330.png

 

 

Let me know if this worked for you.


     Manoj
     Find me on LinkedIn

Avatar

Level 7

Thanks @Manoj_Kumar_ 

Will this logic work with DB Enums? Also, we are looking at not hard-coding any conditions Instead trying to use a Mapping Table and refer it from there? Any ideas around it would be helpful

Avatar

Community Advisor

Hello @Ssb_94 

 

Yes, It will work for the DB enums only if correct xpath and schema is added. For the conditions, you will have to hard code them.


     Manoj
     Find me on LinkedIn

Avatar

Administrator

Hi @Ssb_94,

 

Were you able to resolve this query with the help of any of the given solutions or do you still need more help here? Do let us know.


Thanks!



Sukrity Wadhwa