The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group

Slack Signup
Newsletter Optin
Help Desk

Using conditional logic/conditionals to set hidden field value

Labels

This Discussion is public

Notifications

Is there a way to set a hidden field value based on the answers to questions on that same form?

Example:

Say I want to simplify whether a lead is "qualified" or not.  There may be 5 drop down fields above.  Some of them have multiple acceptable/qualified answers.  I'd like to use either conditional logic or conditionals within the field to enter "yes" for a "Qualified?" hidden field if and only if they have selected acceptable responses for each of the 5 questions above.

I've tried a couple of ways, but rather than sway the responses, I'll just wait and see what the community says.

Related to this issue is that "Like" seems not useful/usable for drop down fields when building conditional logic.  At one point, I had set the acceptable responses for a drop down to have a value of the response plus an asterisk ("*").  My thought was to then use conditional logic to select any responses that were "like" "*".  However when working with the conditional logic builder, you can still only select one response and you can't type anything... so it seems identical to "equal to" in that regard.

Thanks in advance for ideas here.  Feel like Formidable is completely capable of this and I'm just missing the "aha" moment.

Use "separate values" for your dropdowns. Set good answers to 1, great answers to 2, neutral answers to zero, bad answers to -1, etc.

Calculate the default value for your hidden field as the sum of the dropdowns in your form ([78] + [83] where 78 and 83 are the field IDs of you dropdowns). Rather than making the hidden field hidden, make it visible to users with the appropriate role so you can see the results.

This will give you a "score" rather than a yes/no qualification. Keep in mind that Formidable stores the "separate value" and not the text that was submitted. If you have more than one answer for a given dropdown with the same sore, add text to your separate value in addition to the score you assign to each answer so you will be able to recognize what answer was submitted. The calculation will add the number in the separate value and ignore the text.

roja's answer is a great solution. Another alternative is to use Formidable hooks if you are comfortable writing PHP code. It is especially needed if your logic become very complex.
https://formidableforms.com/knowledgebase/frm_pre_create_entry/
https://formidableforms.com/knowledgebase/frm_pre_update_entry/

Thanks very much to both of you.

Roja... I'd thought about doing exactly what you suggest, but this was the "aha" moment for me...

"The calculation will add the number in the separate value and ignore the text."

Since I have multiple acceptable answers for some of the questions but they need to have the same value to make the logic work, I couldn't figure out how to do math but still have it store the text.  I think your solution will work well.

One followup, though, is there a way to store "yes" in the field if the calculation yields a score of 5?  Or do I just need to remember that 5 means yes?

Sujeevan... thanks for your response and links as well.  I'm trying to keep as much of this within the standard Formidable interface/tool as I can so I'm going to try roja's solution first.

Let me also say that you gave a kickass answer to Mark Holgate's  question about saving multiple drafts.  What you suggested and do is exactly what I've done for clients who need this kind of functionality for a number of years.  (I also started the save more than one draft feature request some four years ago now.)  Anyway, he hadn't responded yet but I thought you deserved kudos for that.  Appreciate your active role in helping folks in this forum.

If you really need the "qualified" value to be saved in a field along with the other fields in the form, I would add a new "qualified" text field and set it to yes or no via a custom validation PHP routine based on the score field. This requires custom code but is relatively easy. Alternatively, why not create a view that shows all of the form submissions sorted by score? Using a view, you can easily display whether or not a candidate is qualified.

[if 77 greater_than="4"]Yes[/if 77][if 77 less_than="5"]No[/if 77]

Where 77 is the hidden "score" field. You can even make the qualified candidates pop out with a little (forgive me) inline styling:

[if 77 greater_than="4"]<span style="color: green;">Yes</span>[/if 77][if 77 less_than="5"]No[/if 77]

To me, views are what makes Formidable "kickass" ;)

Thank you for the kudos. Also, I voted for your feature request (yes, Ideally an inbuilt solution is better)

Discussion closed.