Disable "fill-in" in a choice field with this options set

Hi @Ilia,

thanx for you prompt response.

Indeed, I created already something like

  • SharePoint txt-field "fieldValue"
  • "dummy" PlumSail dropdown control "fieldName" (not bound to any SharePoint field)
  • some javascript logic that
    • populates the options in the dropdown
    • checks if the SharePoint field "fieldValue" has a value and sets the option of "fieldName" active
    • adds an action to the dropdown "fieldName" to populate "fieldValue" with the newly choosen option

So basically it's the same you suggested: using a unbound control to populate a SharePoint txt-field

For your reference, code here:

    async function changeDropDownField(fieldName, fieldValue, listName, columnName, columnNameExtra) {

        // get values for choice field
        let items = await pnp.sp.web.lists.getByTitle(listName).items.orderBy(columnName, true)();
        //console.log(items);

        // generic function to extract a column from a 2dim array
        function extractColumn(arr, column) {
            return arr.map(x => x[column])
        }

        // get the options of the dropdown field
        let myOptions = extractColumn(items, columnName);
        //console.log(myOptions);

        // set the options of the dropdown field
        fd.field(fieldName).widget.dataSource.data(myOptions);

        // find select value (stored in a corresponding text field) and set this option active  
        let index = myOptions.indexOf(fd.field(fieldValue).value);
        //console.log(index);
        fd.field(fieldName).widget.select(index);

        // add action to update the dropdown field
        function addAction(fieldName) {
            function myAction() {
                fd.field(fieldValue).value = fd.field(fieldName).value;
            }

            // Calling myAction value changes
            fd.field(fieldName).$on('change', myAction);

            // Calling myAction on form loading
            // myAction();

        }

        addAction(fieldName);

        // bug: je kan nog niet werken met lokale variabelen in de template
        // zie ook
        // https://community.plumsail.com/t/choice-field-how-to-use-local-variables-in-widgetoptions-template/14960
        myItems = items;
        myColumnName = columnName;
        myColumnNameExtra = columnNameExtra;

        // create template for custom rendering
        var template = '';
        //template += '#: console.log(data) # '
        //template += '#: console.log( items.find(item => item["DS_code"] == data)["DS_naam"] ) # '
        //template += '#: console.log(myGlobalVar) # '
        template += '<div style="white-space:nowrap;">';
        template += '<span style="'
        template += 'display: inline-block;'
        template += 'width:150px;'
        template += 'overflow: hidden;'
        template += 'white-space:nowrap;'
        template += 'text-overflow:ellipsis;'
        template += 'border-right: 1px solid silver;'
        template += '">'
        template += '#: data # '
        template += '</span> ';

        template += '<span style="'
        template += 'display: inline-block;'
        template += 'width:550px;'
        template += 'overflow: hidden;'
        template += 'white-space:nowrap;'
        template += 'text-overflow:ellipsis;'
        template += '">'
        template += '#: myItems.find(item => item[myColumnName] == data)[myColumnNameExtra] # '
        template += '</span> ';

        template += '</div>';

        fd.field(fieldName).widgetOptions = {
            template: template
        }
    }

PS.
Same problem here applies using local variables in templates, see also