Default item for Lookup List

Hi,

I encounter a problem with the Lookup component. We want to implement a convenient feature for users because they need to select an item from the lookup list and there may be over 30 lookup fields in the Sub List they need to fill in.

The feature behaviour is:
If any lookup in a Sub List only contains one item. Then the item is selected by default and shown to the user in the sub list

The first question for us is whether we don’t know how to count the number of items of a lookup in a Sub List via Expression Editor. The current solution is calling Query Data List API via HTTP Request to get the count but it seems quite complicated for development. Is there any simple way for counting the number of items in a lookup?

The second question is if we want to set a lookup with a default item, this must trigger the Change Value action from any input field of the current row of a sub-list. Is it possible to set the default item of lookups in a sub-list during the page load?

Thanks a lot

Best regards,
Andy

I’m afraid that the answer to both of your questions is no. Unfortunately, there is no easy way to pre-select an option for a list lookup control.

Regards,
Frank

Hi Frank

Thanks a lot

Will it possible be a feature in the future?

Best regards,
Andy

Hi Andy,

Default value for Lookup control could be an option. But defaulting if only one choice is available will be a challenge.

Regards,
Frank

Hi Frank,

Thanks a lot

For the second question about setting value for all rows of a column in a Sub List when Page Load. Is there no way even a complicated method?

Also when user clicks the “Add Item” in Sub List, it also cannot set the value for a column in this new row

Thanks a lot

Best regards,
Andy

Hi Andy,

One possible solution would involve disabling the “Add Item” function for a sub list, while implementing a button that triggers the action to add new line to it. For reference, please see the following sample custom codes.


export class CodeInApplication implements CodeInComp {
    execute(context: CodeInContext, fieldsValues: any) {
        return new Promise((resolve, reject) => {
            const params = context.params;
            const fieldId = params["varId"];

            let list = fieldsValues[fieldId];

            if (!list) {
                list = [];
            }

            list.push({ field_1: `Initial value: ${list.length}` });
            context.setFieldValue(fieldId, [...list]);

            resolve(true);
        });
    }

    requiredFields(params) {
        return [params["varId"]];
    }

    requiredModules() {
        return [];
    }

    description() {
        return "Add a row to list";
    }

    inputParameters() {
        return [{
            id: "varId",
            type: "string",
            desc: "Varaible ID of the list"
        }] as InputParameter[];
    }
}

Regards,
Frank