Confiforms: Prevent deletion of dependent entries

Mandy Butschke-Lange August 16, 2024

I have a form “form1” with a text field “option”. I use the values entered here in a “form2” as a smart dropdown.

Is there a way to prevent an entry from being deleted in “form1” if this entry has already been used in “form2”?

1 answer

1 accepted

0 votes
Answer accepted
Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 16, 2024

Hi @Mandy Butschke-Lange 

You can add a "Validation on Delete" rule - https://wiki.vertuna.com/display/CONFIFORMS/ConfiForms+Field+Definition+Rules#ConfiFormsFieldDefinitionRules-Validateondelete

And utilize the queryCount function to check the number of records matching in another form (and if that's larger than 0 then the rule will trigger and abort the delete operation)

https://wiki.vertuna.com/display/CONFIFORMS/Virtual+functions

Alex

Mandy Butschke-Lange August 19, 2024

Hi @Alex Medved _ConfiForms_ 

thanks for your help. This works perfectly for field type "Smart Dropdown". But when I change the field type to "Smart Multi-Select" unfortunatly it doesn't work anymore. It seems like the "queryCount"-function doesn't work for "Smart Multi Select"? Do you have an advise how I can get this working?

Here is my code for the "Smart Dropdown" (field "Dropdown" in "form1") where everything works fine. The “Dropdown” field in “form1” should actually be a "Smart Multi Select".

<ac:structured-macro ac:name="confiform" ac:schema-version="1" ac:macro-id="404f0cac-3c3b-484e-a56c-a51aaebd2947"><ac:parameter ac:name="hideAdminUI">true</ac:parameter><ac:parameter ac:name="formName">form1</ac:parameter><ac:parameter ac:name="autoDelete">true</ac:parameter><ac:parameter ac:name="allowReads">true</ac:parameter><ac:rich-text-body>
<p class="auto-cursor-target"><br /></p><ac:structured-macro ac:name="confiform-entry-register" ac:schema-version="1" ac:macro-id="ab168557-cf1e-4649-bba6-dc52f806bb11"><ac:parameter ac:name="formName">form1</ac:parameter><ac:parameter ac:name="registrationButtonLabel">Add new entry</ac:parameter><ac:rich-text-body>
<p><br /></p></ac:rich-text-body></ac:structured-macro>
<h3><ac:structured-macro ac:name="confiform-field-definition" ac:schema-version="1" ac:macro-id="daa13408-13e9-4cfe-b9fe-077d8ee31099"><ac:parameter ac:name="fieldName">Dropdown</ac:parameter><ac:parameter ac:name="fieldLabel">Dropdown</ac:parameter><ac:parameter ac:name="values">[3682352296|DropdownValues|DropdownValue|true||]</ac:parameter><ac:parameter ac:name="type">smartselect</ac:parameter></ac:structured-macro></h3>
<h3><ac:structured-macro ac:name="confiform-field-definition" ac:schema-version="1" ac:macro-id="27177bfb-af43-4209-8a0c-9ad995c6fb6a"><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:structured-macro></h3>
<p><ac:structured-macro ac:name="confiform-field-definition" ac:schema-version="1" ac:macro-id="889ea4d6-8da7-486f-b478-91951b994469"><ac:parameter ac:name="fieldName">DropdownID</ac:parameter><ac:parameter ac:name="fieldLabel">Dropdown ID</ac:parameter><ac:parameter ac:name="type">hidden</ac:parameter></ac:structured-macro></p><ac:structured-macro ac:name="confiform-ifttt" ac:schema-version="1" ac:macro-id="a11307f5-36bc-4008-834b-89b01a0cdcbc"><ac:parameter ac:name="extras3">true</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;DropdownID=[entry.Dropdown.id]</ac:parameter><ac:rich-text-body>
<p><br /></p></ac:rich-text-body></ac:structured-macro><ac:structured-macro ac:name="confiform-ifttt" ac:schema-version="1" ac:macro-id="80bbcd8b-3b99-48e4-bd04-6e34539c4066"><ac:parameter ac:name="extras3">true</ac:parameter><ac:parameter ac:name="action">Create ConfiForms Entry</ac:parameter><ac:parameter ac:name="event">onCreated</ac:parameter><ac:parameter ac:name="title">entryId=[entry.id]&amp;DropdownID=[entry.Dropdown.id]</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:name="confiform-table" ac:schema-version="1" ac:macro-id="7e85e8a9-6ddb-4ab0-bce9-c6693c05a507"><ac:parameter ac:name="pager">NO LIMIT</ac:parameter><ac:parameter ac:name="formName">form1</ac:parameter><ac:rich-text-body>
<h1 class="auto-cursor-target"><ac:structured-macro ac:name="confiform-field" ac:schema-version="1" ac:macro-id="b9678db2-82a8-4b01-ada2-8b677c46fb20"><ac:parameter ac:name="fieldName">id</ac:parameter></ac:structured-macro></h1>
<p class="auto-cursor-target"><ac:structured-macro ac:name="confiform-field" ac:schema-version="1" ac:macro-id="eb98c894-e239-41ae-a3dc-da768d699378"><ac:parameter ac:name="fieldName">Dropdown</ac:parameter></ac:structured-macro></p>
<p class="auto-cursor-target"><ac:structured-macro ac:name="confiform-field" ac:schema-version="1" ac:macro-id="7f48af44-0187-4581-910b-240414b2cefb"><ac:parameter ac:name="fieldName">Name</ac:parameter></ac:structured-macro></p>
<p class="auto-cursor-target"><ac:structured-macro ac:name="confiform-field" ac:schema-version="1" ac:macro-id="61367dbf-a87e-4b7c-b9e7-75dda2ac9857"><ac:parameter ac:name="fieldName">DropdownID</ac:parameter></ac:structured-macro></p><ac:structured-macro ac:name="confiform-entry-edit" ac:schema-version="1" ac:macro-id="42acb172-e9a1-4126-a798-96049efd90af"><ac:rich-text-body>
<p><br /></p></ac:rich-text-body></ac:structured-macro></ac:rich-text-body></ac:structured-macro>
<p><br /></p>
<p><br /></p>
<p>Dropdown Values</p><ac:structured-macro ac:name="confiform" ac:schema-version="1" ac:macro-id="d00a03ea-57aa-419c-9a55-63f896f78ab6"><ac:parameter ac:name="hideAdminUI">true</ac:parameter><ac:parameter ac:name="formName">DropdownValues</ac:parameter><ac:parameter ac:name="autoDelete">true</ac:parameter><ac:parameter ac:name="allowReads">true</ac:parameter><ac:rich-text-body>
<p class="auto-cursor-target"><br /></p><ac:structured-macro ac:name="confiform-entry-register" ac:schema-version="1" ac:macro-id="072e6c7f-20cf-4ff9-9c30-9eaaa421275c"><ac:parameter ac:name="css">background-color:#442EE0</ac:parameter><ac:parameter ac:name="formName">DropdownValues</ac:parameter><ac:parameter ac:name="registrationButtonLabel">Add new item</ac:parameter><ac:rich-text-body>
<p><br /></p></ac:rich-text-body></ac:structured-macro>
<h3><ac:structured-macro ac:name="confiform-field-definition" ac:schema-version="1" ac:macro-id="e3623cb6-e8be-4103-aa95-e7a93afa8a14"><ac:parameter ac:name="fieldName">DropdownValue</ac:parameter><ac:parameter ac:name="fieldLabel">DropdownValue</ac:parameter><ac:parameter ac:name="values">false[]</ac:parameter><ac:parameter ac:name="fieldDescription">Please enter the name of the CPM process you want to add</ac:parameter><ac:parameter ac:name="type">text</ac:parameter><ac:parameter ac:name="required">true</ac:parameter></ac:structured-macro></h3>
<p><ac:structured-macro ac:name="confiform-field-definition-rules" ac:schema-version="1" ac:macro-id="b9e061b3-6ff8-47d0-8f39-aa1ed0dbe582"><ac:parameter ac:name="condition">id.queryCount(form1:@self;DropdownID:[entry.id]):&gt;0</ac:parameter><ac:parameter ac:name="fieldName">Dropdown value is in use</ac:parameter><ac:parameter ac:name="action">Validate on delete</ac:parameter></ac:structured-macro></p>
<p><br /></p></ac:rich-text-body></ac:structured-macro><ac:structured-macro ac:name="confiform-table" ac:schema-version="1" ac:macro-id="7354f908-361f-4330-a497-ec04957d67bd"><ac:parameter ac:name="pager">NO LIMIT</ac:parameter><ac:parameter ac:name="formName">DropdownValues</ac:parameter><ac:parameter ac:name="debugMode">true</ac:parameter><ac:rich-text-body>
<p class="auto-cursor-target"><br /></p>
<p class="auto-cursor-target"><ac:structured-macro ac:name="confiform-field" ac:schema-version="1" ac:macro-id="8d2032fe-57e5-4e9b-8d4c-44e7e89aac1f"><ac:parameter ac:name="fieldName">id</ac:parameter></ac:structured-macro></p>
<p class="auto-cursor-target"><ac:structured-macro ac:name="confiform-field" ac:schema-version="1" ac:macro-id="5625a1b4-94bc-4242-afc4-b9a91c231896"><ac:parameter ac:name="fieldName">DropdownValue</ac:parameter></ac:structured-macro></p>
<p class="auto-cursor-target"><ac:structured-macro ac:name="confiform-field" ac:schema-version="1" ac:macro-id="02670e15-b156-478e-92ec-56406d0d53a0"><ac:parameter ac:name="overrideLabel">Count used dropdown values</ac:parameter><ac:parameter ac:name="fieldName">id.queryCount(form1:@self;DropdownID:[entry.id])</ac:parameter></ac:structured-macro></p><ac:structured-macro ac:name="confiform-entry-edit" ac:schema-version="1" ac:macro-id="a1147782-624c-43a7-b5c4-045e7fef0806"><ac:rich-text-body>
<p><br /></p></ac:rich-text-body></ac:structured-macro></ac:rich-text-body></ac:structured-macro>
<p><br /></p>

 Mandy

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 19, 2024

Same as with single choice fields

See the example below (you dont need a temporary field as in your configuration)

<ac:structured-macro ac:macro-id="404f0cac-3c3b-484e-a56c-a51aaebd2947" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="hideAdminUI">true</ac:parameter>
<ac:parameter ac:name="formName">form1</ac:parameter>
<ac:parameter ac:name="autoDelete">true</ac:parameter>
<ac:parameter ac:name="allowReads">true</ac:parameter>
<ac:rich-text-body>
<p class="auto-cursor-target">
<br/>
</p>
<ac:structured-macro ac:macro-id="ab168557-cf1e-4649-bba6-dc52f806bb11" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="formName">form1</ac:parameter>
<ac:parameter ac:name="registrationButtonLabel">Add new entry</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<h3>
<ac:structured-macro ac:macro-id="c5819915-d492-4d48-98fb-031cccc2b13f" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">Dropdown</ac:parameter>
<ac:parameter ac:name="fieldLabel">Dropdown</ac:parameter>
<ac:parameter ac:name="values">[3682352296|DropdownValues|DropdownValue|true||]</ac:parameter>
<ac:parameter ac:name="type">smartmultiselect</ac:parameter>
</ac:structured-macro>
</h3>
<h3>
<ac:structured-macro ac:macro-id="27177bfb-af43-4209-8a0c-9ad995c6fb6a" 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:structured-macro>
</h3>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="7e85e8a9-6ddb-4ab0-bce9-c6693c05a507" ac:name="confiform-table" ac:schema-version="1">
<ac:parameter ac:name="pager">NO LIMIT</ac:parameter>
<ac:parameter ac:name="formName">form1</ac:parameter>
<ac:rich-text-body>
<h1 class="auto-cursor-target">
<ac:structured-macro ac:macro-id="b9678db2-82a8-4b01-ada2-8b677c46fb20" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">id</ac:parameter>
</ac:structured-macro>
</h1>
<p class="auto-cursor-target">
<ac:structured-macro ac:macro-id="eb98c894-e239-41ae-a3dc-da768d699378" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">Dropdown</ac:parameter>
</ac:structured-macro>
</p>
<p class="auto-cursor-target">
<ac:structured-macro ac:macro-id="7f48af44-0187-4581-910b-240414b2cefb" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">Name</ac:parameter>
</ac:structured-macro>
</p>
<p class="auto-cursor-target">
<ac:structured-macro ac:macro-id="61367dbf-a87e-4b7c-b9e7-75dda2ac9857" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">DropdownID</ac:parameter>
</ac:structured-macro>
</p>
<ac:structured-macro ac:macro-id="42acb172-e9a1-4126-a798-96049efd90af" ac:name="confiform-entry-edit" ac:schema-version="1">
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<br/>
</p>
<p>
<br/>
</p>
<p>Dropdown Values</p>
<ac:structured-macro ac:macro-id="d00a03ea-57aa-419c-9a55-63f896f78ab6" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="hideAdminUI">true</ac:parameter>
<ac:parameter ac:name="formName">DropdownValues</ac:parameter>
<ac:parameter ac:name="autoDelete">true</ac:parameter>
<ac:parameter ac:name="allowReads">true</ac:parameter>
<ac:rich-text-body>
<p class="auto-cursor-target">
<br/>
</p>
<ac:structured-macro ac:macro-id="072e6c7f-20cf-4ff9-9c30-9eaaa421275c" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="css">background-color:#442EE0</ac:parameter>
<ac:parameter ac:name="formName">DropdownValues</ac:parameter>
<ac:parameter ac:name="registrationButtonLabel">Add new item</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<h3>
<ac:structured-macro ac:macro-id="e3623cb6-e8be-4103-aa95-e7a93afa8a14" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">DropdownValue</ac:parameter>
<ac:parameter ac:name="fieldLabel">DropdownValue</ac:parameter>
<ac:parameter ac:name="values">false[]</ac:parameter>
<ac:parameter ac:name="fieldDescription">Please enter the name of the CPM process you want to add</ac:parameter>
<ac:parameter ac:name="type">text</ac:parameter>
<ac:parameter ac:name="required">true</ac:parameter>
</ac:structured-macro>
</h3>
<p>
<ac:structured-macro ac:macro-id="1125ac13-3776-4aea-bd60-2c77cebaa511" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">id.queryCount(form1:@self;Dropdown:[entry.id]):&gt;0</ac:parameter>
<ac:parameter ac:name="fieldName">Dropdown value is in use</ac:parameter>
<ac:parameter ac:name="action">Validate on delete</ac:parameter>
</ac:structured-macro>
</p>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="7354f908-361f-4330-a497-ec04957d67bd" ac:name="confiform-table" ac:schema-version="1">
<ac:parameter ac:name="pager">NO LIMIT</ac:parameter>
<ac:parameter ac:name="formName">DropdownValues</ac:parameter>
<ac:parameter ac:name="debugMode">true</ac:parameter>
<ac:rich-text-body>
<p class="auto-cursor-target">
<br/>
</p>
<p class="auto-cursor-target">
<ac:structured-macro ac:macro-id="8d2032fe-57e5-4e9b-8d4c-44e7e89aac1f" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">id</ac:parameter>
</ac:structured-macro>
</p>
<p class="auto-cursor-target">
<ac:structured-macro ac:macro-id="5625a1b4-94bc-4242-afc4-b9a91c231896" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">DropdownValue</ac:parameter>
</ac:structured-macro>
</p>
<p class="auto-cursor-target">
<ac:structured-macro ac:macro-id="682163f8-216e-4fb1-a45d-7888471d8882" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="overrideLabel">Count used dropdown values</ac:parameter>
<ac:parameter ac:name="fieldName">id.queryCount(form1:@self;Dropdown:[entry.id])</ac:parameter>
</ac:structured-macro>
</p>
<ac:structured-macro ac:macro-id="a1147782-624c-43a7-b5c4-045e7fef0806" ac:name="confiform-entry-edit" ac:schema-version="1">
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<br/>
</p>

 

Mandy Butschke-Lange August 19, 2024

Thank you very much for your quick reply. I have also just found my error and it now works as in your example.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events