Smart dropdown lookups - how to make work?
Asked by Paul Ward:

First up, <https://wiki.vertuna.com/display/CONFIFORMS/Using+ConfiForms+Field+Definition+Rule+to+lookup+value+from+another+form> does not work - the lookup value is not saved in the second form as intended.

Problem: I have one form which I want to use to look up data to populate fields in a second form based on selection in a smart drop down. The smart drop down I have working no problem - it populates from the second table and the selected value gets written ok on register.

I have added a filed definition rule \*with no filter\*, and my text filed gets populated ok, but due to no filter it of course contains all rows from the lookup table. This is where I get stuck, I simply can not work out any filter which works. The broken example referenced above doesn't help, and a most of the other examples I can find are based on the db lookup so don't help either. Doc for the action 'Look up and set value" action is incomplete at best

Advice?

Storage format below:

```
<ac:structured-macro ac:macro-id="8cc80eef-7bc8-4bd4-9ca4-5b7b58e569ee" ac:name="confiform-entry-register" ac:schema-version="1">
 <ac:parameter ac:name="formName">Engagements</ac:parameter>
 <ac:parameter ac:name="registrationButtonLabel">Engage!</ac:parameter>
 <ac:rich-text-body>
 <p>
 <ac:structured-macro ac:macro-id="0027bb8a-76db-43e9-8af2-ffbaaec1fec8" ac:name="confiform-field" ac:schema-version="1">
 <ac:parameter ac:name="fieldName">ID</ac:parameter>
 <ac:parameter ac:name="withLabel">true</ac:parameter>
 </ac:structured-macro> <ac:structured-macro ac:macro-id="f69390d4-96ab-46df-8c85-63464974dd3e" ac:name="confiform-field" ac:schema-version="1">
 <ac:parameter ac:name="fieldName">Description</ac:parameter>
 </ac:structured-macro>
 </p>
 <p>?</p>
 </ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="c351a40f-b19c-4b16-8694-b48f69fa749a" ac:name="confiform" ac:schema-version="1">
 <ac:parameter ac:name="formName">Engagements</ac:parameter>
 <ac:parameter ac:name="registrationFormTitle">Engagements</ac:parameter>
 <ac:rich-text-body>
 <p>
 <ac:structured-macro ac:macro-id="e6ddfd28-4a04-41a7-ac22-777273070dab" ac:name="confiform-field-definition" ac:schema-version="1">
 <ac:parameter ac:name="fieldName">ID</ac:parameter>
 <ac:parameter ac:name="fieldLabel">Cert ID</ac:parameter>
 <ac:parameter ac:name="values">[78076595|certs|ID|true|true|]</ac:parameter>
 <ac:parameter ac:name="extras">false[]</ac:parameter>
 <ac:parameter ac:name="type">smartselect2</ac:parameter>
 </ac:structured-macro>
 </p>
 <p>
 <ac:structured-macro ac:macro-id="c145e7fa-89d5-418b-b013-3b3a69b52bac" ac:name="confiform-field-definition" ac:schema-version="1">
 <ac:parameter ac:name="fieldName">Description</ac:parameter>
 <ac:parameter ac:name="fieldLabel">Description</ac:parameter>
 <ac:parameter ac:name="values">[78076595|certs|Description|true||]</ac:parameter>
 <ac:parameter ac:name="type">text</ac:parameter>
 </ac:structured-macro>
 </p>
 <p>
 <ac:structured-macro ac:macro-id="475058e5-bffa-497a-a820-2a36f1702879" ac:name="confiform-field-definition" ac:schema-version="1">
 <ac:parameter ac:name="fieldName">Contact</ac:parameter>
 <ac:parameter ac:name="fieldLabel">Contact</ac:parameter>
 <ac:parameter ac:name="type">read_only</ac:parameter>
 </ac:structured-macro>
 </p>
 <p>
 <ac:structured-macro ac:macro-id="d3bd97b2-959a-45d4-b012-f087b8f716ed" ac:name="confiform-field-definition-rules" ac:schema-version="1">
 <ac:parameter ac:name="fieldName">Description=[entry.Description]&amp;Contact=[entry.Contact]</ac:parameter>
 <ac:parameter ac:name="action">Lookup and set value</ac:parameter>
 <ac:parameter ac:name="onUserActionOnly">true</ac:parameter>
 <ac:parameter ac:name="actionFieldName">ID</ac:parameter>
 <ac:parameter ac:name="values2">certs</ac:parameter>
 </ac:structured-macro>
 </p>
 </ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="640bf551-35a4-4472-b2c4-aa79b6777691" ac:name="confiform" ac:schema-version="1">
 <ac:parameter ac:name="formName">certs</ac:parameter>
 <ac:parameter ac:name="allowReads">true</ac:parameter>
 <ac:rich-text-body>
 <p>
 <ac:structured-macro ac:macro-id="99e01455-92a5-4766-b0cd-8171d9f08ca2" ac:name="confiform-field-definition" ac:schema-version="1">
 <ac:parameter ac:name="fieldName">ID</ac:parameter>
 <ac:parameter ac:name="fieldLabel">CERT ID</ac:parameter>
 <ac:parameter ac:name="type">number</ac:parameter>
 </ac:structured-macro>
 </p>
 <p>
 <ac:structured-macro ac:macro-id="0540caf6-0012-4f44-bec3-210f18272c78" ac:name="confiform-field-definition" ac:schema-version="1">
 <ac:parameter ac:name="fieldName">Contact</ac:parameter>
 <ac:parameter ac:name="fieldLabel">Contact</ac:parameter>
 <ac:parameter ac:name="type">text</ac:parameter>
 </ac:structured-macro>
 </p>
 <p>
 <ac:structured-macro ac:macro-id="24d89692-b612-45a6-8ebf-b66a4357efc5" ac:name="confiform-field-definition" ac:schema-version="1">
 <ac:parameter ac:name="fieldName">Description</ac:parameter>
 <ac:parameter ac:name="fieldLabel">Description</ac:parameter>
 <ac:parameter ac:name="type">text</ac:parameter>
 </ac:structured-macro>
 </p>
 </ac:rich-text-body>
</ac:structured-macro>
```


Answers:
author: Paul Ward
body: update: I now have it working with a smart classifier instead of smart dropdown, which is OK but doesn't allow type-ahead searching so not 100% ideal

Follow up question - the definition rule seems to fire after selecting an entry in the drop down... is there a way to make it fire as the selection changes?

use case .... as user types in a prior registration ID they see the related description in real time


Tags: confiforms