Field Definition Rule > Lookup & Set Value > Filter lookup using a multi select field reference

Gilberto Cortes February 4, 2022

Objective: Populate a markdown field using a Lookup & Set Value rule

Problem: Markdown field is only populated with one color's instructions and does not populate instructions from the remaining selected colors.

Question: Is there a way to populate the markdown field with each selected color's instructions?

Setup:

Form One has the following fields:

  • text field named color with the follow values: orange, blue, blue-green, green, red
  • markdown field named colorInstructions with instructions to create each color

Form Two has the following fields:

  • smart-multi-select field names myColorSelection tied to Form One's color
  • markdown field name myInstructions

Form Two has a field definition rule configured as:

  • Field Name >> myColorSelection
  • Condition >> myColorSelection.color:*blue*
  • Execute only on user action >> unchecked
  • Action to Execute >> Lookup and set value
  • Values to Set >> myInstructions=[entry.colorInstructions.append(\\n\\n)]
  • Lookup Filter >> color:*blue*
  • Source Form Name and Page >> formOne:123456
  • Sorting and Limits >>
  • No event propagation on value change >> unchecked

 

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.
February 5, 2022

Hi

Multi-value fields as arguments in filters are a bit tricky - as you need to construct a filter dynamically

Here is how it is possible - see the screencast below

http://recordit.co/zLiDKLC3Ek

With storage format for the reference

<ac:structured-macro ac:name="confiform" ac:schema-version="1" ac:macro-id="2a1e65d3-3cb0-4384-b470-5e7ee66a86e6"><ac:parameter ac:name="hideAdminUI">true</ac:parameter><ac:parameter ac:name="formName">formOne</ac:parameter><ac:rich-text-body>
<p><ac:structured-macro ac:name="confiform-field-definition" ac:schema-version="1" ac:macro-id="3a4af94b-d006-4111-af6a-e33beff920fb"><ac:parameter ac:name="fieldName">color</ac:parameter><ac:parameter ac:name="type">text</ac:parameter><ac:parameter ac:name="macroHash">1218298903</ac:parameter></ac:structured-macro></p>
<p><ac:structured-macro ac:name="confiform-field-definition" ac:schema-version="1" ac:macro-id="cf1d9745-7f5e-4d8a-a6e2-a58d0f018887"><ac:parameter ac:name="fieldName">colorInstructions</ac:parameter><ac:parameter ac:name="type">markdown</ac:parameter><ac:parameter ac:name="macroHash">265096862</ac:parameter></ac:structured-macro></p><ac:structured-macro ac:name="confiform-entry-register" ac:schema-version="1" ac:macro-id="45cf2744-dd15-400e-8e4f-b6bfb0cf122d"><ac:parameter ac:name="formName">formOne</ac:parameter><ac:rich-text-body>
<p><br /></p></ac:rich-text-body></ac:structured-macro>
<p class="auto-cursor-target"><br /></p></ac:rich-text-body></ac:structured-macro>
<p class="auto-cursor-target">Available colors</p><ac:structured-macro ac:name="confiform-table" ac:schema-version="1" ac:macro-id="ca7e5227-5903-448f-a277-e48a3905add3"><ac:parameter ac:name="formName">formOne</ac:parameter><ac:rich-text-body>
<p><br /></p></ac:rich-text-body></ac:structured-macro>
<p class="auto-cursor-target"><br /></p>
<p><br /></p><ac:structured-macro ac:name="confiform" ac:schema-version="1" ac:macro-id="543c7323-852d-4732-89a4-7981c6fb8ac2"><ac:parameter ac:name="hideAdminUI">true</ac:parameter><ac:parameter ac:name="formName">formTwo</ac:parameter><ac:rich-text-body>
<p><ac:structured-macro ac:name="confiform-field-definition" ac:schema-version="1" ac:macro-id="e87e39b8-6e3e-4ab8-b43c-893d04f5da09"><ac:parameter ac:name="fieldName">myColorSelection</ac:parameter><ac:parameter ac:name="values">[1508966425|formOne|color|true||]</ac:parameter><ac:parameter ac:name="type">smartmultiselect</ac:parameter><ac:parameter ac:name="macroHash">460968723</ac:parameter></ac:structured-macro></p>
<p><ac:structured-macro ac:name="confiform-field-definition" ac:schema-version="1" ac:macro-id="874eb52e-f139-4f8c-a9b8-44e556cf46eb"><ac:parameter ac:name="fieldName">myInstructions</ac:parameter><ac:parameter ac:name="type">markdown</ac:parameter><ac:parameter ac:name="macroHash">1238172543</ac:parameter></ac:structured-macro></p>
<p><br /></p>
<p>-- rule</p>
<p><ac:structured-macro ac:name="confiform-field-definition-rules" ac:schema-version="1" ac:macro-id="1f04ff9c-ad2e-4363-ac39-be6cb1cfb1d3"><ac:parameter ac:name="condition">!myColorSelection:[empty]</ac:parameter><ac:parameter ac:name="fieldName">myInstructions=[entry.colorInstructions.append(\n\n)]</ac:parameter><ac:parameter ac:name="values">id:[entry.myColorSelection.transform(id).join( OR id:)]</ac:parameter><ac:parameter ac:name="action">Lookup and set value</ac:parameter><ac:parameter ac:name="actionFieldName">myColorSelection</ac:parameter><ac:parameter ac:name="values2">formOne</ac:parameter><ac:parameter ac:name="macroHash">-505735227</ac:parameter></ac:structured-macro></p>
<p><ac:structured-macro ac:name="confiform-field-definition-rules" ac:schema-version="1" ac:macro-id="648bea34-dc68-4d34-a6ad-2df74b6743cb"><ac:parameter ac:name="condition">myColorSelection:[empty]</ac:parameter><ac:parameter ac:name="fieldName">myInstructions</ac:parameter><ac:parameter ac:name="action">Reset value</ac:parameter><ac:parameter ac:name="actionFieldName">myColorSelection</ac:parameter><ac:parameter ac:name="macroHash">1378536391</ac:parameter></ac:structured-macro></p>
<p><br /></p>
<p class="auto-cursor-target"><br /></p></ac:rich-text-body></ac:structured-macro>
<p class="auto-cursor-target"><br /></p><ac:structured-macro ac:name="confiform-entry-register" ac:schema-version="1" ac:macro-id="ba197809-af25-4d58-b8b2-7a6f0e197d4b"><ac:parameter ac:name="formName">formTwo</ac:parameter><ac:rich-text-body>
<p><br /></p></ac:rich-text-body></ac:structured-macro>

I use the "join" and "transform" functions to get arguments (field values I need) right

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

As with all the ConfiForms smart fields the filtering is done using the UUIDs of the records (as this is what they store - a link to the record, that is why I check against the "id" field in the formOne in my "lookup filter")

Hope it helps

Alex

Gilberto Cortes February 7, 2022

Thanks Alex, I will try this out today.

Gilberto Cortes February 7, 2022

Alex, thank you! You definitely got me past a mental wall on this. I did have to tweak it to fit my particular needs. I just wanted to populate the myInstructions field ONLY if the option selected contained the word "blue":

 

Rule #1: If myColorSelection has less than 2 options selected that start with blue then lookup and set value. (I had to do a separate rule for 1 option because the .append(\r\r) would not work correctly for a single selection)

  • Field Name >> myColorSelection
  • Condition >> !myColorSelection:[empty] AND myColorSelection.asFilteredBy(color:blue*).asLength:<2
  • Execute only on user action >> unchecked
  • Action to Execute >> Lookup and set value
  • Values to Set >> myInstructions=[entry.color] [entry.colorInstructions]
  • Lookup Filter >> color:blue* AND id:[entry.myColorSelection.transform(id).join( OR color:blue* AND id:)]
  • Source Form Name and Page >> formOne:123456
  • Sorting and Limits >>
  • No event propagation on value change >> unchecked

Rule #2: If myColorSelection has more than 1 option selected that start with blue then lookup and set value. (I had to do a separate rule for 1 option because the .append(\r\r) would not work correctly for a single selection)

  • Field Name >> myColorSelection
  • Condition >> !myColorSelection:[empty] AND myColorSelection.asFilteredBy(color:blue*).asLength:>1
  • Execute only on user action >> unchecked
  • Action to Execute >> Lookup and set value
  • Values to Set >> myInstructions=[entry.color] [entry.colorInstructions.append(\r\r)]
  • Lookup Filter >> color:blue* AND id:[entry.myColorSelection.transform(id).join( OR color:blue* AND id:)]
  • Source Form Name and Page >> formOne:123456
  • Sorting and Limits >>
  • No event propagation on value change >> unchecked
  • Field Name >> myColorSelection
  • Condition >> !myColorSelection:[empty] AND myColorSelection.asFilteredBy(color:blue*).asLength:>1
  • Execute only on user action >> unchecked
  • Action to Execute >> Reset Value
  • Actionable Field Name >> myInstructions

Rule #3: If myColorSelection is empty then reset value. 

  • Field Name >> myColorSelection
  • Condition >> !myColorSelection:[empty] AND myColorSelection.asFilteredBy(color:blue*).asLength:>1
  • Execute only on user action >> unchecked
  • Action to Execute >> Reset Value
  • Actionable Field Name >> myInstructions

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events