Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This is a demo to show how the dropdown could be filtered using the "usedcount" also counting how many time the name was used

There is also a mechanism used to prevent the deletion of the data if it is used in the other form

Meaning that the form that uses the data from a source form sets the counter about how many times the data have been used. And there is a delete rule on source form to check the "used counter" and fail the deletion of the used count is more than 0


Info
titleMuch simpler solution with new function

Virtual functions has now a function to query count (queryCount) matching your criteria, using this function in the condition of "Validate on delete" rule is much more simpler than implementing the counter and counting the use of values



 
ConfiForms Form Definition
formNamef


profileNameprofileNametext

 


usedUsedfalsehidden

usedcountUsed count0hidden

used:truetrueCreate ConfiForms EntryonModifiedentryId=[entry.id]&usedusedcount=([entry.usedcount]+1)&used=truef:12222622 


used:falsetrueCreate ConfiForms EntryonModifiedentryId=[entry.id]&usedusedcount=([entry.usedcount]-1)&used=falsef:12222622

 


usedcount:>0You cannot edit this record (it is used (referenced) in other form)Validate on delete

 
ConfiForms Form Definition
formNamef1


profileNameprofileName[12222622|f|profileName|true||]smartselect

trueCreate ConfiForms EntryonCreatedentryId=[entry.profileName]&used=truef:12222622

 


truehasChanged(profileName):trueCreate ConfiForms EntryonModifiedentryId=[entry._previousState.profileName]&used=falsef:12222622 


truehasChanged(profileName):trueCreate ConfiForms EntryonModifiedentryId=[entry.profileName]&used=truef:12222622 


trueCreate ConfiForms EntryonDeletedentryId=[entry.profileName]&used=falsef:12222622 


Records in f

ConfiForms TableView
formNamef

profileName

usedcount

 


Recods in f2 


ConfiForms TableView
formNamef1

profileName 


Source code for the solution

Code Block
<ac:structured-macro ac:macro-id="323f6007-384e-41ce-8d66-7d65c436f281" ac:name="confiform" ac:schema-version="1">
  <ac:parameter ac:name="formName">f01</ac:parameter>
  <ac:rich-text-body>
    <ac:structured-macro ac:macro-id="ef798ae4-d4a7-42c4-8c3e-4b93c2f56286" ac:name="confiform-entry-register" ac:schema-version="1">
      <ac:rich-text-body>
        <p> </p>
      </ac:rich-text-body>
    </ac:structured-macro>
    <p>
      <ac:structured-macro ac:macro-id="b9706e4b-d98e-4cdf-8452-07c715edc161" ac:name="confiform-field-definition" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">profileName</ac:parameter>
        <ac:parameter ac:name="fieldLabel">profileName</ac:parameter>
        <ac:parameter ac:name="type">text</ac:parameter>
      </ac:structured-macro>
    </p>
    <p> </p>
    <p>
      <ac:structured-macro ac:macro-id="4d2758d3-4c25-4466-84be-3340a02e5f5d" ac:name="confiform-field-definition" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">used</ac:parameter>
        <ac:parameter ac:name="fieldLabel">Used</ac:parameter>
        <ac:parameter ac:name="values">false</ac:parameter>
        <ac:parameter ac:name="type">hidden</ac:parameter>
      </ac:structured-macro>
    </p>
    <p>
      <ac:structured-macro ac:macro-id="6690c163-f11d-4f0c-b892-2c7b3f14459e" ac:name="confiform-field-definition" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">usedcount</ac:parameter>
        <ac:parameter ac:name="fieldLabel">Used count</ac:parameter>
        <ac:parameter ac:name="values">0</ac:parameter>
        <ac:parameter ac:name="type">hidden</ac:parameter>
      </ac:structured-macro>
    </p>
    <ac:structured-macro ac:macro-id="11c04fe8-aa43-49d0-a460-a0b1cec79e01" ac:name="confiform-ifttt" ac:schema-version="1">
      <ac:parameter ac:name="condition">used:true</ac:parameter>
      <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;usedcount=([entry.usedcount]+1)&amp;used=true</ac:parameter>
      <ac:parameter ac:name="who">f01:12222622</ac:parameter>
      <ac:rich-text-body>
        <p> </p>
      </ac:rich-text-body>
    </ac:structured-macro>
    <ac:structured-macro ac:macro-id="fef83b62-6842-4374-8d32-3b13abeb38ed" ac:name="confiform-ifttt" ac:schema-version="1">
      <ac:parameter ac:name="condition">used:false</ac:parameter>
      <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;usedcount=([entry.usedcount]-1)&amp;used=false</ac:parameter>
      <ac:parameter ac:name="who">f01:12222622</ac:parameter>
      <ac:rich-text-body>
        <p> </p>
      </ac:rich-text-body>
    </ac:structured-macro>
    <p>
      <ac:structured-macro ac:macro-id="965ed455-9a0a-461f-93ab-49fad96f376b" ac:name="confiform-field-definition-rules" ac:schema-version="1">
        <ac:parameter ac:name="condition">usedcount:&gt;0</ac:parameter>
        <ac:parameter ac:name="fieldName">You cannot edit this record (it is used (referenced) in other form)</ac:parameter>
        <ac:parameter ac:name="action">Validate on delete</ac:parameter>
      </ac:structured-macro>
    </p>
  </ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="3aebe087-a1d1-4b14-9367-7c87a4efd011" ac:name="confiform" ac:schema-version="1">
  <ac:parameter ac:name="formName">f11</ac:parameter>
  <ac:rich-text-body>
    <ac:structured-macro ac:macro-id="28803937-25f6-4738-92e5-ea53d8edae7f" ac:name="confiform-entry-register" ac:schema-version="1">
      <ac:rich-text-body>
        <p> </p>
      </ac:rich-text-body>
    </ac:structured-macro>
    <p>
      <ac:structured-macro ac:macro-id="578f2f88-9e05-4491-9a34-40c139c23152" ac:name="confiform-field-definition" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">profileName</ac:parameter>
        <ac:parameter ac:name="fieldLabel">profileName</ac:parameter>
        <ac:parameter ac:name="values">[12222622|f|profileName|true||]</ac:parameter>
        <ac:parameter ac:name="type">smartselect</ac:parameter>
      </ac:structured-macro>
    </p>
    <ac:structured-macro ac:macro-id="ea265827-080b-4f1f-b859-7728658da04f" ac:name="confiform-ifttt" ac:schema-version="1">
      <ac:parameter ac:name="extras5">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.profileName]&amp;used=true</ac:parameter>
      <ac:parameter ac:name="who">f:12222622</ac:parameter>
      <ac:rich-text-body>
        <p> </p>
      </ac:rich-text-body>
    </ac:structured-macro>
    <ac:structured-macro ac:macro-id="a9b4c52e-dc2c-412c-a353-0609b30ae72f" ac:name="confiform-ifttt" ac:schema-version="1">
      <ac:parameter ac:name="extras5">true</ac:parameter>
      <ac:parameter ac:name="condition">hasChanged(profileName):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._previousState.profileName]&amp;used=false</ac:parameter>
      <ac:parameter ac:name="who">f01:12222622</ac:parameter>
      <ac:rich-text-body>
        <p> </p>
      </ac:rich-text-body>
    </ac:structured-macro>
    <ac:structured-macro ac:macro-id="ecd1c878-ddfb-4ce4-9f06-796a3334935b" ac:name="confiform-ifttt" ac:schema-version="1">
      <ac:parameter ac:name="extras5">true</ac:parameter>
      <ac:parameter ac:name="condition">hasChanged(profileName):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.profileName]&amp;used=true</ac:parameter>
      <ac:parameter ac:name="who">f01:12222622</ac:parameter>
      <ac:rich-text-body>
        <p> </p>
      </ac:rich-text-body>
    </ac:structured-macro>
    <ac:structured-macro ac:macro-id="01a76f72-1c9f-44d5-be3b-38038a419dc0" ac:name="confiform-ifttt" ac:schema-version="1">
      <ac:parameter ac:name="extras5">true</ac:parameter>
      <ac:parameter ac:name="action">Create ConfiForms Entry</ac:parameter>
      <ac:parameter ac:name="event">onDeleted</ac:parameter>
      <ac:parameter ac:name="title">entryId=[entry.profileName]&amp;used=false</ac:parameter>
      <ac:parameter ac:name="who">f01:12222622</ac:parameter>
      <ac:rich-text-body>
        <p> </p>
      </ac:rich-text-body>
    </ac:structured-macro>
  </ac:rich-text-body>
</ac:structured-macro>
<p>Records in f</p>
<ac:structured-macro ac:macro-id="a08b6b66-1070-48a8-b56b-1416630b937a" ac:name="confiform-table" ac:schema-version="1">
  <ac:parameter ac:name="formName">f01</ac:parameter>
  <ac:rich-text-body>
    <p>
      <ac:structured-macro ac:macro-id="542e9d47-c466-4ae8-948d-45b961c32214" ac:name="confiform-field" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">profileName</ac:parameter>
      </ac:structured-macro>
    </p>
    <p>
      <ac:structured-macro ac:macro-id="fd0b30d1-4185-4a29-b5e3-83d6cb47aeaf" ac:name="confiform-field" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">usedcount</ac:parameter>
      </ac:structured-macro>
    </p>
  </ac:rich-text-body>
</ac:structured-macro>
<p> </p>
<p>Recods in f2</p>
<p> </p>
<ac:structured-macro ac:macro-id="b9cb1824-20f7-49f2-afd2-dfa95775899b" ac:name="confiform-table" ac:schema-version="1">
  <ac:parameter ac:name="formName">f11</ac:parameter>
  <ac:rich-text-body>
    <p>
      <ac:structured-macro ac:macro-id="b5bc0a57-2d00-4e21-973b-b98a3f369ca0" ac:name="confiform-field" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">profileName</ac:parameter>
      </ac:structured-macro>
    </p>
    <p> </p>
  </ac:rich-text-body>
</ac:structured-macro>