Page tree

Versions Compared

Key

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

...

ConfiForms Form Definition
formNamef
confluence-administratorstrueINLINE


somefieldJust some field heretext

ownedBy:[entry.ownedBy] AND _count:>1 AND _user.userInSecurityGroup(confluence-administrators):falseSorry, you have already registeredValidation rule dataset

Image Added


We will add a rule with the following settings

Image Added

Condition is defined as follows:

Code Block
ownedBy:[entry.ownedBy] AND _count:>1 AND _user.userInSecurityGroup(confluence-administrators):false


We check for record ownership and see how many of these are already registered and we do it only if a user is not in the "confluence-administrators" security group (userInSecurityGroup is the function available in ConfiForms Virtual functions). _count is the context variable you can access from a context Accessing field values and properties#Additionalvaluesavailableinthecontext


Image Added


Users who are not in the "confluence-administrators" user group will be allowed to enter only one record


Complete form looks like this

Image Added

And when used by a non admin and there is an attempt to enter another record 


Image Added


Storage format for the solution

Code Block
<ac:structured-macro ac:macro-id="57d87851-3132-4c5c-b13f-af3423293b4f" ac:name="confiform" ac:schema-version="1">
  <ac:parameter ac:name="formName">f1</ac:parameter>
  <ac:rich-text-body>
    <ac:structured-macro ac:macro-id="d594d9a9-09e8-49e5-b436-d7f1d5c57c86" ac:name="confiform-entry-register" ac:schema-version="1">
      <ac:parameter ac:name="embedded">true</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="501d3676-5e26-496f-8554-8828abaa37a6" ac:name="confiform-field-definition" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">somefield</ac:parameter>
        <ac:parameter ac:name="fieldLabel">Just some field here</ac:parameter>
        <ac:parameter ac:name="type">text</ac:parameter>
      </ac:structured-macro>
    </p>
    <p>
      <ac:structured-macro ac:macro-id="6b07cd3c-bfc2-4b3c-9158-d0df83c6dce0" ac:name="confiform-field-definition-rules" ac:schema-version="1">
        <ac:parameter ac:name="condition">ownedBy:[entry.ownedBy] AND _count:>1 AND _user.userInSecurityGroup(confluence-administrators):false</ac:parameter>
        <ac:parameter ac:name="fieldName">Sorry, you have already registered</ac:parameter>
        <ac:parameter ac:name="action">Validation rule dataset</ac:parameter>
      </ac:structured-macro>
    </p>
  </ac:rich-text-body>
</ac:structured-macro>