How to create many-many relationship between two confiform forms
Asked by Piotr Gugnowski:

Hey, I would like to have two forms that are in many-many relationship. For ex. I have tables:

People: \[name, list of tasks to do\]

Tasks: \[task name, people assigned to that task\]

I would like to have intrgration rule that will adjust other form rows so estabilished relation will be visible in two tables properly.

It is essential that after editing for ex. list of tasks relation ship will be updated in both forms to display proper relationship. Including case of deleting some relationships.

It would be cool if list of task to do and people assigned to projects were smart multiselect fields and I could see demo of this solution.

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


Answers:
author: Alex Medved _ConfiForms_
body: Hi

Consider this example. It shows the one-directional update of a multi-select field. You will need to configure something like that for the tasks form as well if you need the changes to be trackable in both directions

Demo:

<http://recordit.co/FwxvMQ92Mj>

Configuration:

```
<p>
<a class="" href="https://community.atlassian.com/t5/Confluence-questions/How-to-create-many-many-relationship-between-two-confiform-forms/qaq-p/2422571">https://community.atlassian.com/t5/Confluence-questions/How-to-create-many-many-relationship-between-two-confiform-forms/qaq-p/2422571</a>
</p>
<ac:structured-macro ac:macro-id="f312bf04-f11b-44b3-b770-f01fdb0ad200" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">people</ac:parameter>
<ac:parameter ac:name="debugMode">true</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="930fa83b-3a0e-45b5-9d1d-ea3773d08f88" 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="f60a1ec3-50e5-4ac3-aaae-1c791022ab8f" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">tasks</ac:parameter>
<ac:parameter ac:name="fieldLabel">Tasks</ac:parameter>
<ac:parameter ac:name="values">[148111546|tasks|taskName|true||]</ac:parameter>
<ac:parameter ac:name="type">smartmultiselect</ac:parameter>
</ac:structured-macro>
</p>
<ac:structured-macro ac:macro-id="2041808e-c092-47d3-bba3-e79e5a425485" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="registrationButtonLabel">Register person</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br/>
</p>
<ac:structured-macro ac:macro-id="d4b163b8-e609-4ab3-b346-95f472a5d2ce" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="condition">!tasks:[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">people=[entry.id.asEntryRef(entry.people).asList],[entry.id]</ac:parameter>
<ac:parameter ac:name="extras2">id:[entry.tasks.transform(id).join( OR id:)]</ac:parameter>
<ac:parameter ac:name="who">tasks</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br/>
</p>
<ac:structured-macro ac:macro-id="381e791b-c43b-4e2c-89ff-b85a049065e9" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="extras5">true</ac:parameter>
<ac:parameter ac:name="extras4">true</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">removePerson=[entry.id]</ac:parameter>
<ac:parameter ac:name="extras2">people:[entry.id]</ac:parameter>
<ac:parameter ac:name="who">tasks</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br/>
</p>
<ac:structured-macro ac:macro-id="d47b6830-c7f9-46d3-8d81-9c4e96516013" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="condition">!tasks:[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">onModified</ac:parameter>
<ac:parameter ac:name="title">people=[entry.id.asEntryRef(entry.people).asList],[entry.id]</ac:parameter>
<ac:parameter ac:name="extras2">id:[entry.tasks.transform(id).join( OR id:)]</ac:parameter>
<ac:parameter ac:name="who">tasks</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>People</p>
<ac:structured-macro ac:macro-id="70b74172-f823-4de0-ab78-2e529f717794" ac:name="confiform-table" ac:schema-version="1">
<ac:parameter ac:name="formName">people</ac:parameter>
<ac:rich-text-body>
<p class="auto-cursor-target">
<br/>
</p>
<ac:structured-macro ac:macro-id="21dec8bc-b3bf-4789-b9f8-f52a4a076b9d" ac:name="confiform-entry-edit" ac:schema-version="1">
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<br/>
</p>
<ac:structured-macro ac:macro-id="28ef97b8-cce5-4ff5-a2cc-6f731083f915" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">tasks</ac:parameter>
<ac:parameter ac:name="debugMode">true</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="4658bc91-d920-4f92-bb0b-8f8c4584ee14" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">taskName</ac:parameter>
<ac:parameter ac:name="fieldLabel">Task 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="1a214511-7e27-41db-b094-f282ac22edfe" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">people</ac:parameter>
<ac:parameter ac:name="fieldLabel">People</ac:parameter>
<ac:parameter ac:name="values">[148111546|people|name|true||]</ac:parameter>
<ac:parameter ac:name="type">smartmultiselect</ac:parameter>
</ac:structured-macro>
</p>
<p>
<br/>
</p>
<ac:structured-macro ac:macro-id="50ad5ee0-7bce-4acd-8e15-3865ff6bbccf" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="registrationButtonLabel">Register task</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="b1ed4024-968f-432f-a1fd-ebcf2e3ba24d" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="condition">!removePerson:[empty]</ac:parameter>
<ac:parameter ac:name="action">Create ConfiForms Entry</ac:parameter>
<ac:parameter ac:name="event">onModified</ac:parameter>
<ac:parameter ac:name="title">entryId=[entry.id]&amp;people=[entry.people.remove([entry.removePerson]).transform(id).asList]&amp;removePerson=</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>Tasks</p>
<ac:structured-macro ac:macro-id="782eabac-8aae-40c2-add5-53dde0681b11" ac:name="confiform-table" ac:schema-version="1">
<ac:parameter ac:name="formName">tasks</ac:parameter>
<ac:rich-text-body>
<p class="auto-cursor-target">
<br/>
</p>
<ac:structured-macro ac:macro-id="18690f06-b35b-4c3d-b11a-202d8cfc06ee" ac:name="confiform-entry-edit" ac:schema-version="1">
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br/>
</p>
```

You will need to reconfigure smart fields to point at each other.. as they are currently configured to use the page in my example server

Alex


Tags: confiforms

confluence-server

server