Field Values Based on Previous Selections | Community
Skip to main content
Level 2
March 16, 2015
Solved

Field Values Based on Previous Selections

  • March 16, 2015
  • 4 replies
  • 2635 views

I'm working in Forms 2.0 and know how to hide/show fields. What I would like to do is show/hide field values based on multiple selections: 
FIELD NAME - Product name: FIELD VALUES- Product A, Product B, Product C, Product D....
FIELD NAME - Support Representative: FIELD VALUES - Rep A, Rep B, Rep C

If Product A is chosen, only Rep A displays in the picklist
If Product B is chosen, only Rep B displays in the picklist
If Product C
 is chosen, only Rep C displays in the picklist
If Product A AND B
 are chosen, only Reps A AND B display in the picklist
If Product A AND C
 are chosen, only Reps A AND C display in the picklist
If Product B AND C
 are chosen, only Reps B AND C display in the picklist
If Product D is chosen, Reps A, B and C display in the picklist
 
My values go well past three values and I am trying to avoid creating numerous new fields to hide/show and would prefer to use a single field if possible. 

 



 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman
@Chris, like @Josh says this is something to build in JS using the Forms 2.0 API... something like this demo I just put together. (Maybe to add to the Forms 2.0 Cookbook I'm working on to compile similar crazy stuff I've done lately.)

This example uses dependency rules stored as JSON -- the rules are actually embedded in the form as a supplementary rich text component so you can manage them within the Form Editor (not that the editor has any idea what they mean, but it keeps everything centralize). Rules look like this:
{
  "Product A": {
    "Rep A": true
  },
  "Product B": {
    "Rep B": true
  },
  "Product C": {
    "Rep C": true
  },
  "Product D": {
    "Rep A": true,
    "Rep B": true,
    "Rep C": true
  }
}

4 replies

Josh_Hill13
Level 10
March 16, 2015
I think Visibility Rules will not let you do this. They work best with few variables and choices.

I would recommend using a custom javascript to control this. It will work better.
SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
March 17, 2015
@Chris, like @Josh says this is something to build in JS using the Forms 2.0 API... something like this demo I just put together. (Maybe to add to the Forms 2.0 Cookbook I'm working on to compile similar crazy stuff I've done lately.)

This example uses dependency rules stored as JSON -- the rules are actually embedded in the form as a supplementary rich text component so you can manage them within the Form Editor (not that the editor has any idea what they mean, but it keeps everything centralize). Rules look like this:
{
  "Product A": {
    "Rep A": true
  },
  "Product B": {
    "Rep B": true
  },
  "Product C": {
    "Rep C": true
  },
  "Product D": {
    "Rep A": true,
    "Rep B": true,
    "Rep C": true
  }
}
ChrisPe14Author
Level 2
March 17, 2015

Sanford - your example is exactly what I am looking for, although I'm not clear regarding the placement of the script. I'm not a developer, but can read/write code based on examples like the one you provided and know that once I understand the placement I can make the code you shared work for me . Thanks for your help!
 
Regards,

Chris

SanfordWhiteman
Level 10
March 17, 2015
@Chris Feel free to contact me if you want to chat more about it.