You are viewing limited content. For full access, please sign in.

Question

Question

Append Choices to Lookup Results Breaks Lookup Matching

asked on October 18

I have a dropdown field that is configured as Required and has 6 choices configured and the "Append choices to lookup results" option is selected. The same field is part of a Lookup Rule where when another field is populated it populates 7 fields.

With this configuration the field does not populate from the lookup. If I uncheck the "Append choices to lookup results" the lookup matching works again, but I lose the choices being appended.

Is there a workaround for these scenarios? Is this a bug?

Using Forms 12.0.2503.10378

0 0

Replies

replied one day ago

I have a workaround that appears to be working for me on version 12.0.2503.10378 - at least in the Form Preview, I haven't tested in an actual process.
Javascript for Layout Designer:

/*Option 1 - Manual List of Options:
Rather than using the "Append choices to lookup results"
option to manually add values to the dropdown,
we are using this Javascript. This ensures that the single
value loaded from the lookup is auto-selected.
This function runs when the field is changed by the lookup
and when the form is first loaded.*/
LFForm.onFieldChange(AddDepartmentsToDropdown, {variableName: "department"});
AddDepartmentsToDropdown();
function AddDepartmentsToDropdown() {
  const additionalValues = [
    "Human Resources",
    "Accounting",
    "Contact Center"
    ];
  LFForm.changeFieldOptions( {variableName: "department"}, additionalValues, "add" );
}

/*Option 2 - List of Options from Lookup:
Rather than using two lookups to populate
options in the dropdown (one for the single selected
value and one for the list of possible values).
We are using this Javascript. This ensures that the single
value loaded from the lookup is auto-selected.
This does require two fields, one for each lookup.
The departments_from_lookup field can be hidden from view.
This function runs when the fields are changed by the
lookups and when the form is first loaded.*/
LFForm.onFieldChange(AddDepartmentsToDropdown2, {variableName: "departments_from_lookup"});
LFForm.onFieldChange(AddDepartmentsToDropdown2, {variableName: "department2"});
AddDepartmentsToDropdown2();
function AddDepartmentsToDropdown2() {
  let fullList = LFForm.findFieldsByVariableName("departments_from_lookup")[0].options;
  LFForm.changeFieldOptions( {variableName: "department2"}, fullList, "add" );
}

 

2 0
replied 3 hours ago

So now I'm testing this in an actual process, and the instance says the value is saved from what I selected on the first submission, but it doesn't show on the field itself on later tasks, and nothing I do with the field settings or Javascript seems to resolve it.  It seems like the changes they made to the code for lookups on dropdowns is buggy or something.

0 0
replied on October 19

Hi Blake, I can't reproduce the issue based on the general scenario you described. I recommend opening a support ticket and providing the business process details.

0 0
replied on October 22

I could be mistaken or totally misunderstanding…  But I feel like to have the “Append Choices to Lookup Results” option continue to work properly, you really need to also have the “Assign Values to Choices” option turned on too.

It might be a bug that it doesn’t work well without the values enabled, but I feel like this is something I have encountered as well.

0 0
replied on October 22

Sorry for the earlier misunderstanding. It's not a bug. It is expected behavior that no choice is automatically selected when the "Append Choices to Lookup Results" option is checked. In this case, the lookup results will only appear as choices, along with the appended ones.

0 0
replied on October 22

Zanbo, the issue is not that a choice is not automatically selected. The issue is that there are no options populated in the drop down field.

0 0
replied on October 23

Sorry, I mixed it up with the issue Daniel posted. Actually, they are different issues. In your case, you're saying that after checking "Append choices to lookup results", the dropdown only shows the 6 choices you configured—am I correct? Are the lookup results the same as the 6 choices you set? Duplicate choices will be automatically removed. If they’re not the same, and the lookup results don’t appear at all, then I still suggest opening a ticket for further investigation, as the issue might be related to the database or other configurations.

0 0
replied on October 24

After doing some additional testing, it appears that what I am trying to do works in the Classic Designer, but not in the Modern Designer.

Classic Designer

Modern Designer

You can see from the gifs that I created two forms, one using Classic the other using Modern. Each have the same two fields. The RF Contracting Entity fields have choices assigned to them and have the Append choices to lookup results selected.

The lookup rules are also configured the same. With the Classic Form, it selects the RF Contracting Entity value from the lookup based on the Vendor Name and populates the choices. With the Modern Form it does not select the RF Contracting Entity value from the lookup, but populates the choices.

0 0
replied on October 26

I can't see the text clearly as the resolution of gifs is too low. After populating the choices, are the dropdown lists in the Classic Form and Modern Form the same? Is the only difference that the RF Contracting Entity value from lookup is not selected?

0 0
replied on October 26

Sorry for the resolution. Yes, in the classic designer the option in the drop-down field is selected whereas in the Modern designer the option is not. Both populate the appended choices.

0 0
replied on October 26

When "Append choices to lookup results" is checked, the lookup result value is displayed alongside existing choices in the dropdown list, with duplicates removed, but it is not auto-selected. I've checked and confirmed that this is the expected behavior in Forms 12 Modern Form, although it differs from that of the Classic Form.
As an alternative, you can put the dropdown into collection/table, and select the "as new sets/rows" in lookup rules, then the lookup result value will be auto-selected.
Sorry for any confusion caused.

0 0
replied one day ago

Is there a reason that behavior was changed?

0 0
replied one day ago

The behavior was changed in bug #538516 on Cloud and applied to Self-hosted Modern Form. After that (starting with Forms 12), the lookup result will be selected only if there is one result at the end (including appended choices).

0 0
replied one day ago

What was the bug that was trying to be fixed? Having a dropdown field that has set available options, either set at the field level itself or populated from a database, and then having an option selected for that dropdown based on a database lookup, while still showing the other available options is a pretty standard practice for web forms in general. I'm just trying to understand what the reasoning was behind removing it, especially if it was because of a bug.

2 0
replied 14 hours ago

The bug was just about the lookup rules behavior change we discussed. It seems the team ultimately decided to update the behavior. I’m not certain about the reasoning behind this decision, but I’ve shared your feedback with the team.

1 0
replied 2 hours ago

The behavior was changed in bug #538516 on Cloud and applied to Self-hosted Modern Form. After that (starting with Forms 12), the lookup result will be selected only if there is one result at the end (including appended choices).

It looks to me like it is also undoing the selection from a prior task submission.

0 0
replied an hour ago

Found a work around:
Add an extra single line field to pull the lookup (keep hidden) and use JavaScript to move the result to the drop-down field. You can still see the default selections in the drop-down and change the answer.

Here is the script: 

//Set Drop Down Field with lookup field value//

LFForm.onLookupDone(function () {
    const valueArray = LFForm.getFieldValues({ fieldId: 4 });
    const valueToSet = Array.isArray(valueArray) ? valueArray.join(' ') : valueArray;

    if (valueToSet && valueToSet.trim() !== '') {
        LFForm.setFieldValues({ fieldId: 3 }, valueToSet);
    }
}, { lookupRuleId: 1 });

 

Change the Field IDs based on the hidden field, dropdown field and your lookup rule.

0 0
replied on October 22

Sorry for the earlier misunderstanding. It's not a bug. It is expected behavior that no choice is automatically selected when the "Append Choices to Lookup Results" option is checked. In this case, the lookup results will only appear as choices, along with the appended ones.

You are not allowed to follow up in this post.

Sign in to reply to this post.