Displaying a selection in a multiple choice lookup

Question

When I select the necessary items, they are not displayed in the lookup, although I can retrieve them from this.get('ResponsibleLookUp').

Kindly advise how I can display them in the lookup for the user to see what he has selected.

Answer

Below is an example of a lookup with multiple choice, whose selection display is bound to the string, the selection key storage is bound to the array.

define("CasePage", ["CasePageResources", "terrasoft", "LookupUtilities"],
    function(resources, Terrasoft, LookupUtilities) {
        return {
            entitySchemaName: "Case",
            details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,
            attributes: {
                "UsrVirtualCity": {
                    dataValueType: Terrasoft.DataValueType.TEXT,
                    type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN
                },
                "UsrVirtualCityArray": {
                    dataValueType: Terrasoft.DataValueType.CUSTOM_OBJECT,
                    type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN
                }
            },
            diff: /**SCHEMA_DIFF*/[
                {
                    "operation": "insert",
                    "name": "Number",
                    "values": {
                        "layout": { "colSpan": 24, "rowSpan": 1, "column": 0, "row": 4 },
                        "bindTo": "UsrVirtualCity",
                        "caption": "virtual city",
                        "controlConfig": {
                            "className": "Terrasoft.TextEdit",
                            "rightIconClasses": ["custom-right-item", "lookup-edit-right-icon"],
                            "rightIconClick": {
                                "bindTo": "testClick"
                            }
                        }
                    },
                    "parentName": "SolutionTab_gridLayout",
                    "propertyName": "items",
                    "index": 6
                }
            ]/**SCHEMA_DIFF*/,
            methods: {
                onEntityInitialized: function() {
                    this.callParent(arguments);
                    // just for debug:
                    document.scope = this;
                },
                testClick: function() {
                    var config = {
                        entitySchemaName: "City",
                        multiSelect: true
                    };
                    LookupUtilities.Open(this.sandbox, config, this.onTestClickComplete, this, null, false, false);
                },
                onTestClickComplete: function(cities) {
                    if (cities.selectedRows.getCount() > 0) {
                        var citiesItems = cities.selectedRows.getItems();
                        var displayValue = "";
                        for (var i = 0; i < citiesItems.length; i++) {
                            displayValue = displayValue + citiesItems[i].displayValue + "; ";
                        }
                        displayValue = displayValue.substring(0, displayValue.length - 2);
                        this.set("UsrVirtualCity", displayValue);
                        var citiesKeys = cities.selectedRows.getKeys();
                        this.set("UsrVirtualCityArray", citiesKeys);
                    }
                }
            },
            rules: {}
        };
});

 

Like 0

Like

Share

4 comments

Dear S.Kobizka,

This works fine but the data that are selected are not obtained when the right-Icon is pressed.. How can we re-pass the selected values to the lookup?

Plus, is there any idea on how to pass for the dropdown a filter? For example giving the lookup a countryId and then only the cities in this country will be shown..

Mohammad Yahfoufi,

Firstly, there is no currently an option to pass already selected items to the second lookup opening of lookup window. We will pass your suggestion on to the developers for them to take such option into consideration for future product updates.

Secondly, regarding filtration for the lookup. You can use business rules in the Section Wizard, so to specify the filtration rules. For example here I have specified exact country to filter my custom field by. You can set any other, which would suit your business task.

http://prntscr.com/mw8mb4

https://academy.bpmonline.com/documents/administration/7-13/business-ru…

Regards,

Anastasia

Anastasia Botezat,

Thank you for your reply. I noticed in Business Process that the selected items can be passed to the lookup but I couldnt follow up the code. Here is a sample:

Mohammad Yahfoufi,

This functionality was additionally developed specifically for the process design elements.

In case you decide to replicate this functionality, please take a look at ProcessLookupPageMixin and EntityColumnLookupPage schemas. Particularlly, DataGrid diff. It has an onclick event handler method, which updates selected entity column property "selected" to true. Therefore, next time you decide to select other columns, the columns having selected property on will be displayed. Though, this requires advanced development skills to implement such functionality.

Regards,

Anastasia

Show all comments