Page tree
Skip to end of metadata
Go to start of metadata

This is the documentation for ConfiForms Server/Data Center app

This short tutorial shows you how to setup a form with conditional validation, which allows only one record per user per month

Consider a very simple form with just one field of type "Date", we name it "mydate"

Just one field and one rule. Everything is in default state, the important bit here is the ConfiForms Rules for Field Definition macro and how it is set up

So, we have a rule to run a validation action across the dataset and this will be executed when the condition is met.

The condition is set as follows:

mydate.formatDate(MM):[entry.mydate.formatDate(MM)] AND _count:>0 AND createdBy:[]

We use Virtual functions here to transforma date field into a month, we use context variable _count and we use context variable called [] to access the current user login

Alternative way of writing the condition (and more modern), using the context variable _user

mydate.formatDate(MM):[entry.mydate.formatDate(MM)] AND _count:>0 AND createdBy:[entry._user]

Complete configuration in storage format is available here

 Click here to expand...
<ac:structured-macro ac:macro-id="e3152962-e681-4234-bed7-44d892da4907" ac:name="confiform" ac:schema-version="1">
  <ac:parameter ac:name="formName">f</ac:parameter>
    <ac:structured-macro ac:macro-id="8dcdefd1-41ab-4847-83b1-77ca5f8b2b8e" ac:name="confiform-entry-register" ac:schema-version="1">
        <p> </p>
      <ac:structured-macro ac:macro-id="82642dea-938e-45c7-a735-d2f6cf7bd96f" ac:name="confiform-field-definition" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">mydate</ac:parameter>
        <ac:parameter ac:name="fieldLabel">My date</ac:parameter>
        <ac:parameter ac:name="type">date</ac:parameter>
      <ac:structured-macro ac:macro-id="71d71948-d0ae-42d2-a66c-e452e8f85bd2" ac:name="confiform-field-definition-rules" ac:schema-version="1">
        <ac:parameter ac:name="condition">mydate.formatDate(MM):[entry.mydate.formatDate(MM)] AND _count:&gt;0 AND createdBy:[]</ac:parameter>
        <ac:parameter ac:name="fieldName">Already exists for this month</ac:parameter>
        <ac:parameter ac:name="action">Validation rule dataset</ac:parameter>
  • No labels