Confiforms - Limit the number of times a dropdown can be selected

Archana
Contributor
July 13, 2023

Hi,

I have a scenario where I need to restrict the number of times users can select a specific value in a dropdown. Eg:

inv_gg.PNG

 

Consider that I have a grocery stories with 5 packs of onions, 10 packs of Tomatoes, 7 packs of apples etc.,

As the customer orders groceries, my inventory should be readjusted. 

When the last pack of onions were ordered, my dropdown value should no longer display onions. If all pf the vegetables are unavailable then make it read only and show out of stock.

How can I achieve this functionality in confiforms. Any help is greatly appreciated. Thank you!

1 answer

1 accepted

1 vote
Answer accepted
Alex Medved _ConfiForms_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 13, 2023

Hi

Where do you store the information about your "current stock" and how do you update that?

Alex

Archana
Contributor
July 14, 2023

I have two options

  1. Store the data as an output of another confi form and updating it there
  2. Directly storing the data while defining the dropdown field in the confirm form and managing it from there

I am currently using the second option. However, if I have to move to first for better solutioning, I can do it.

Alex Medved _ConfiForms_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 19, 2023

Hi @Archana 

Honestly, it is up to you to pick the option you like... but I would go about it with something like this

Consider the following example (please note it works only for the new registrations and does not handle stock updates on edits. Feel free to extend and modify as needed)

http://recordit.co/C4Mz3jqpaq

Full configuration as page storage format:

<ac:structured-macro ac:macro-id="6bb480d4-9aa2-4da2-a738-6f63201a7795" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">stock</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="1dfa1de7-e39a-4c2a-8dec-2f2fee0c9873" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">type</ac:parameter>
<ac:parameter ac:name="fieldLabel">Type</ac:parameter>
<ac:parameter ac:name="values">false[1=Vegetables|2=Fruits|3=Greens|]</ac:parameter>
<ac:parameter ac:name="type">select</ac:parameter>
<ac:parameter ac:name="required">true</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="5c97a55c-769a-4a58-86fe-cbcd5705cd70" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">name</ac:parameter>
<ac:parameter ac:name="fieldLabel">Name</ac:parameter>
<ac:parameter ac:name="type">text</ac:parameter>
<ac:parameter ac:name="required">true</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="e3b1850a-6b0f-4296-b4e5-a1a57b1d9fb2" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">quantity</ac:parameter>
<ac:parameter ac:name="fieldLabel">Quantity</ac:parameter>
<ac:parameter ac:name="type">number</ac:parameter>
<ac:parameter ac:name="required">true</ac:parameter>
</ac:structured-macro>
</p>
<ac:structured-macro ac:macro-id="8052d5ee-530d-4afc-b920-8d0027d377d8" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="type">Embedded</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<ac:structured-macro ac:macro-id="1ce95641-fb69-43a8-b30c-3c57d86b73e8" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">quantity:&lt;0</ac:parameter>
<ac:parameter ac:name="fieldName">Quantity for [entry.name] (type:[entry.type.label]) cannot be lower than 0</ac:parameter>
<ac:parameter ac:name="action">Validation rule</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="983fa3ef-bc4b-4001-afa4-8fd2d3c4edd3" ac:name="confiform-table" ac:schema-version="1">
<ac:parameter ac:name="formName">stock</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<br/>
</p>
<ac:structured-macro ac:macro-id="f88c024e-50c1-4478-824c-927fb73100d2" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">usingStock</ac:parameter>
<ac:parameter ac:name="debugMode">true</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="670c69ba-d458-4f39-8a56-745c74904db6" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<ac:structured-macro ac:macro-id="2feaa862-7a7b-4b61-ab8d-c7bc8ff17af8" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">vegetables</ac:parameter>
<ac:parameter ac:name="fieldLabel">Vegetables</ac:parameter>
<ac:parameter ac:name="values">[148111527|stock|name|true||]</ac:parameter>
<ac:parameter ac:name="type">smartselect</ac:parameter>
</ac:structured-macro> <ac:structured-macro ac:macro-id="adbc7713-8103-4f11-b668-955d57be3a35" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="fieldName">vegetables</ac:parameter>
<ac:parameter ac:name="values">type:1 AND quantity:&gt;0</ac:parameter>
<ac:parameter ac:name="action">Apply Filter on a field</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="ec38383c-3907-4281-990c-fe3a72559b17" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">fruits</ac:parameter>
<ac:parameter ac:name="fieldLabel">Fruits</ac:parameter>
<ac:parameter ac:name="values">[148111527|stock|name|true||]</ac:parameter>
<ac:parameter ac:name="type">smartselect</ac:parameter>
</ac:structured-macro> <ac:structured-macro ac:macro-id="36d0a47b-ce0f-41e8-af3c-113831501a0b" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="fieldName">fruits</ac:parameter>
<ac:parameter ac:name="values">type:2 AND quantity:&gt;0</ac:parameter>
<ac:parameter ac:name="action">Apply Filter on a field</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="c65a7853-21d4-4293-9903-0ec17f3c0cb9" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">greens</ac:parameter>
<ac:parameter ac:name="fieldLabel">Greens</ac:parameter>
<ac:parameter ac:name="values">[148111527|stock|name|true||]</ac:parameter>
<ac:parameter ac:name="type">smartselect</ac:parameter>
</ac:structured-macro> <ac:structured-macro ac:macro-id="918f71c4-d5f3-4cbc-bc19-6c33b29b729c" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="fieldName">greens</ac:parameter>
<ac:parameter ac:name="values">type:3 AND quantity:&gt;0</ac:parameter>
<ac:parameter ac:name="action">Apply Filter on a field</ac:parameter>
</ac:structured-macro>
</p>
<ac:structured-macro ac:macro-id="8fb43cc1-abb3-4424-8c45-c2cde5dba4e4" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="condition">!vegetables:[empty]</ac:parameter>
<ac:parameter ac:name="extras3">true</ac:parameter>
<ac:parameter ac:name="action">Update ConfiForms entries by filter</ac:parameter>
<ac:parameter ac:name="event">onCreated</ac:parameter>
<ac:parameter ac:name="title">quantity=([entry.id.asEntryRef(entry.quantity)]-1)</ac:parameter>
<ac:parameter ac:name="extras2">id:[entry.vegetables]</ac:parameter>
<ac:parameter ac:name="who">stock</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="c5b43d3f-45e9-4258-bbfd-77084d848c18" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="condition">!fruits:[empty]</ac:parameter>
<ac:parameter ac:name="extras3">true</ac:parameter>
<ac:parameter ac:name="action">Update ConfiForms entries by filter</ac:parameter>
<ac:parameter ac:name="event">onCreated</ac:parameter>
<ac:parameter ac:name="title">quantity=([entry.id.asEntryRef(entry.quantity)]-1)</ac:parameter>
<ac:parameter ac:name="extras2">id:[entry.fruits]</ac:parameter>
<ac:parameter ac:name="who">stock</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="2a0d71d8-0b98-4273-a588-70003f3b4ec2" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="condition">!greens:[empty]</ac:parameter>
<ac:parameter ac:name="extras3">true</ac:parameter>
<ac:parameter ac:name="action">Update ConfiForms entries by filter</ac:parameter>
<ac:parameter ac:name="event">onCreated</ac:parameter>
<ac:parameter ac:name="title">quantity=([entry.id.asEntryRef(entry.quantity)]-1)</ac:parameter>
<ac:parameter ac:name="extras2">id:[entry.greens]</ac:parameter>
<ac:parameter ac:name="who">stock</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="68311cd9-b20b-4897-890b-bdb68e7458b7" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="action">Delete ConfiForms Entry</ac:parameter>
<ac:parameter ac:name="event">onDeleted</ac:parameter>
<ac:parameter ac:name="title">id:[entry.id]</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<br/>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<br/>
</p>

Hope it helps and gives ideas

Alex

Archana
Contributor
July 28, 2023

Thank you so much @Alex Medved _ConfiForms_ 

I tried and I think I am close to what I am looking. I faced a minor issue

I defined quantity as a numeric value and when the integration rules are applied it is considering as text. 

For example, this is how my stock quantity is looking like

Quantity Issue.PNG

Alex Medved _ConfiForms_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 28, 2023

I can only guess, as I dont see what you have done.. but probably your ConfiForms IFTTT that attempts to update the quantity is not correct and doest not have the () around the math expression to make it calculable (evaluated as formula/expression)

Archana
Contributor
July 28, 2023

Hi @Alex Medved _ConfiForms_ 

That’s exactly what has happened. Thank you so much for all your help. This is exactly what I want.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events