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

In ConfiForms we have a number of integration points where you can supply the data from your database tables or views directly to ConfiForms.

One of such integrations is using the ConfiForms Field Definition Rules action called "Lookup and set a DB value"

 

The table we use for the demo is with following structure

 

id name link
1 ConfiForms add-on for Confluence
2 ConfiDoc add-on for Confluence
3 Smart Templates & Pages nice app

 

Here is an example on how to use it. We wil have a simple form which will lookup the plugin link from a database table based on user selection and will set it to the text field (actually a field type called "link" to make the value clickable, but the techniques are the same)

The field "choice" is of type "db dropdown" and link is of type "link"

 

The form looks like this

 

We will add a ConfiForms Field Definition Rules macro to the game

In storage format it looks like this:

<ac:structured-macro ac:macro-id="4b605c7d-bcdb-429d-874b-6a6817e17a79" ac:name="confiform-field-definition-rules" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">link=[entry.pluginlink]</ac:parameter>
        <ac:parameter ac:name="values">select link as "pluginlink" from cd_demo where id = [entry.choice.id]</ac:parameter>
        <ac:parameter ac:name="action">Lookup and set DB value</ac:parameter>
        <ac:parameter ac:name="onUserActionOnly">true</ac:parameter>
        <ac:parameter ac:name="actionFieldName">choice</ac:parameter>
        <ac:parameter ac:name="values2">7422036e-9a6f-4455-92d9-7140131fb9da</ac:parameter>
      </ac:structured-macro>

So what we do here...

  1. we set the rule to be triggered only when the value in field "choice" changes. 
  2. we set it to execute only on user action
  3. we configure it to set the value of the result into a field called link

    link=[entry.pluginlink]
  4. Important note is what is this "pluginlink".. it is actually the column returned by the SQL lookup we configured (see the r)

    select link as "pluginlink" from cd_demo where id = [entry.choice.id]
  5. SQL uses the value from a selected dropdown (it is a dropdown, so we need an ID. See Accessing field values and properties for more details)
  6. When SQL query is executed we get the results back and use the value of a column "pluginlink" to set back to ConfiForms field link