How to automatically set smart multi dropdown in other confiform records
Asked by Piotr Gugnowski:

I would like to set in my confiform entry smart multiselect field that would have reference to other previously entered rows.

In response to this action i wold like to have integration rule that would update their smart multiselect fields that have referenes to other entered rows in such manner that those fields would have new reference to the id of new row that was just created.

To simplify i want that estabilished relation between rows was updated also in referenced rows.

Also i would like how to estabilish that relation when list of references is updated and I would also appreciate explanatory example.

[@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630)


Answers:
author: Alex Medved _ConfiForms_
body: Hi [@Piotr Gugnowski](/t5/user/viewprofilepage/user-id/5269638) and wlecome to this community

Consider this example: <http://recordit.co/tLK1bxIcv3>

And the complete configuration (please note it uses references to smart fields in my page, so will need to reconfigure this a bit)

```
<ac:structured-macro ac:macro-id="a96047a9-6d82-4ce0-810a-9b2d32b89d33" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">masterForm</ac:parameter>
<ac:parameter ac:name="registrationFormTitle">My master form</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="eecc96c7-6ee9-4ae3-885b-83db419653e2" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="formName">masterForm</ac:parameter>
<ac:parameter ac:name="registrationButtonLabel">Register new master record</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<ac:structured-macro ac:macro-id="a3fa62fc-e056-4dd7-ab80-e7c47177abe6" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">name</ac:parameter>
<ac:parameter ac:name="fieldLabel">Just a name</ac:parameter>
<ac:parameter ac:name="type">text</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="ecd5099d-76c1-4a3b-bd60-458ad601ee76" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">choices</ac:parameter>
<ac:parameter ac:name="fieldLabel">choices</ac:parameter>
<ac:parameter ac:name="values">[148111492|choicesForm|choice|true||]</ac:parameter>
<ac:parameter ac:name="type">smartmultiselect</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>Master form</p>
<ac:structured-macro ac:macro-id="a188701b-bd8d-4d61-a0bc-2676ea426e43" ac:name="confiform-table" ac:schema-version="1">
<ac:parameter ac:name="formName">masterForm</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="8743bcfc-48f3-4162-b971-cb0ac75ac524" ac:name="confiform-entry-edit" ac:schema-version="1">
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="c04e824c-7e08-4ab2-b8fd-41f1bf63807b" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">choicesForm</ac:parameter>
<ac:parameter ac:name="debugMode">true</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="769adae6-1b79-42b8-a0cd-6c7344170ff7" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">choice</ac:parameter>
<ac:parameter ac:name="fieldLabel">choice</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="533a1675-2651-4879-bfa2-dbe42a2702af" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">refToMaster</ac:parameter>
<ac:parameter ac:name="fieldLabel">Ref to master</ac:parameter>
<ac:parameter ac:name="values">[148111492|masterForm|name|true||]</ac:parameter>
<ac:parameter ac:name="type">smartselect2</ac:parameter>
</ac:structured-macro>
</p>
<p>
<br/>
</p>
<ac:structured-macro ac:macro-id="e35c4a6a-7dd6-46fe-b6e8-f415f3579c6e" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="condition">!refToMaster:[empty]</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">choices=[entry.refToMaster.choices.transform(id).asList],[entry.id]</ac:parameter>
<ac:parameter ac:name="extras2">id:[entry.refToMaster]</ac:parameter>
<ac:parameter ac:name="who">masterForm:@self</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="09ceae37-cc77-43b9-a9ce-e9569181e5c8" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="condition">!refToMaster:[empty]</ac:parameter>
<ac:parameter ac:name="action">Update ConfiForms entries by filter</ac:parameter>
<ac:parameter ac:name="event">onModified</ac:parameter>
<ac:parameter ac:name="title">choices=[entry.refToMaster.choices.transform(id).asList],[entry.id]</ac:parameter>
<ac:parameter ac:name="extras2">id:[entry.refToMaster]</ac:parameter>
<ac:parameter ac:name="who">masterForm:@self</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
<p>Choices</p>
<ac:structured-macro ac:macro-id="cd9561a2-fe98-4fc6-a57e-42afdef59fd9" ac:name="confiform-table" ac:schema-version="1">
<ac:parameter ac:name="formName">choicesForm</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="b873c13b-165e-4b92-af9f-452350b0e166" ac:name="confiform-entry-edit" ac:schema-version="1">
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="fa774341-eca2-4561-96cc-b49308bf9ba9" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="formName">choicesForm</ac:parameter>
<ac:parameter ac:name="registrationButtonLabel">Register new choice</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
```

Hope it helps

Alex

comments: author: Piotr Gugnowski
body: Thank you for the answer!

In fact i struggle the most with smart multiselect fields. Instead of Dynamic dropdown i would also need smart multiselect, because i need choice field to be in relation with many masterForm records. Basically I still dont know how to estabilish many-to-many relation between those two forms. Moreover I would like to know to modify your demo in such a way that modifying masterForm record would also modify appropriate choicesForm records without generating infinite loop.

Another hard problem that I have to resolve is to properly update other form rows after updating relations in the first form.


author: Alex Medved _ConfiForms_
body: Not sure what you mean by dynamic dropdowns in this context - my example is how to build a parent-child relationship with ConfiForms and smart fields

Creating bi-directional relationships. I deliberately leave all the fields visible (not using rules to hide anything, to make the example easier to understand and extend)

Alex


author: Piotr Gugnowski
body: Hm.. could you please show to how to make this parent-child relation but with inversed control? What I mean is to estabilish relation in master by choosing certain choice values and choice form would update.


author: Alex Medved _ConfiForms_
body: This is exactly what this example does - adds references to parent

Aka "inversed control" as you call it

Alex


author: Piotr Gugnowski
body: I mean the other way of estabilishing a relation. In your demo user has to choose master record from choicesForm. How to estabilish that relation by choosing certain choiceForm rows in master smart multiselect field.


author: Alex Medved _ConfiForms_
body: That is done for you automatically... smart field itself is already a "relation". A link between forms, in one direction initially.

This demo shows how to set up a bi-directional one

Alex


author: Maniumek
body: [@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630) Could you please, show how to adjust masterForm, when deleting some rows from choiceForm? It would be really useful, but it somehow cannot work out for me with the use of .asFilteredBy or .remove. I do not know what do I do incorrectly.


author: Alex Medved _ConfiForms_
body: This demo is about "one to many" relations between forms - there is no need to use the "remove" or "asFilteredBy"

Or at least I dont understand how would you do that and why


author: Maniumek
body: I find it important, to keep relation active/up-to-date no matter what user does with choiceForm (deletes/adds) data. When user decides to delete a row from choice row the whole relation breaks. And that is why I suspect .asFilterBy or .remove functions to be useful, but I didn't manage to work this out.

This would be suuper useful for me and many confiforms users I guess.


author: Maniumek
body: [@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630) Could you please show the extended demo of one-to-many relationship, that stays up-to-date/synchronized even user decides to delete rows from choiceTable? I tried to do this, but with no results.


Tags: confiforms

confluence-server

server