Populate multiple choice extra field in dropdown

Good day !
I have source list, where i have i multiple choice field.


in another list i have a field category, linked to the source list.
Can i populate extra multiple choice field from source in to my current list in a single dropdown field?
fd.field('Dropdown').value=fd.field('Source').value.Error // extra multiple choice field

Hello @ixxxl,

Not sure I understood your request.

The Error column in a source list is a multiple choice dropdown and fd.field('Source') — is a lookup field, is that correct?

If so, you need to define the Error column in the lookup's Extra fields property. Thus, you can get value of the Error column on the form.

But you can't populate a single-choice drop down field with multiple values. You need to change the field type to allow multiple choices.

@Margo
Good day!
Yes you are right. That's my problem ,i tried multiple choice to populate in single.ok thank you!

1 Like

@Margo
May be there is another solution how i can populate single dropdown, based on selected lookup? maybe from extra field multiple line choice?

@ixxxl,

Please describe your case so I could provide the solution. Why do you need to populate a single choice dropdown with data from a multichoice field?

@Margo
i have 2 lists. 1st list like admin source list. 2nd list have a lookup field for list 1.
In second list on editing user must select category (from lookup of titles from list 1) and on selecting to extract from this title some multiple names and put them in single dropdown list 2.


Select in lookup - retragere numerar, and to show in single dropdown field Error(it have 5 values, in a multiple choice field)
in lookup field i put field Error in extra fields

@ixxxl,

If you need the value of the multiple choice field as a string, you can use the join() method and then populate a single choice dropdown field like this:


fd.field('Field1').value = fd.field('Lookup').value.Error.join(' ')

@Margo
Good day ! i tried, and nothing happens .

The function starting on change CMSSubcategorii1 field
image

@ixxxl,

Please check the browser console for the errors.

@Margo
Checked, no errors

@ixxxl,

How do you run the code? Test it in the browser console and debug. You can find instructions in this post:

@Margo

fd.field('Tipul_x0020_adres_x0103_rii').value=fd.field('CMSSubcategorii1').value.Error.join(' ')

i tried in console to put lookup extra values, and there are old values there.

function hideOrShowProblem2() {

    if (fd.field('CMSSubcategorii1').value) {
        // Show the Due Date field
        //  $(fd.field('CMSSubcategorii1').$parent.$el).show();    
        $(fd.field('CMSSubcategorii2').$parent.$el).show();
		fd.field('DropDown2').value = fd.field('CMSSubcategorii1').value.Error.join(' ')
		fd.field('Cauza_x0020_erorii').value = fd.field('CMSSubcategorii1').value.Error.join(' ')
		

    } else {
        // Hide the Due Date field
        // $(fd.field('CMSSubcategorii1').$parent.$el).hide();
        $(fd.field('CMSSubcategorii2').$parent.$el).hide();


    }

}

fd.spRendered(function () {

    function hideOrShowProblem() {

        if (fd.field('CMSCategorii').value) {
            // Show the Due Date field
            if (fd.field('CMSCategorii').value.LookupValue == 'Servicii la ATM') {
                fd.field('CMSSubcategorii1').required = true
            } else {
                fd.field('CMSSubcategorii1').required = false
            }
            $(fd.field('CMSSubcategorii1').$parent.$el).show();
            $(fd.field('CMSSubcategorii2').$parent.$el).hide();

        } else {
            // Hide the Due Date field
            $(fd.field('CMSSubcategorii1').$parent.$el).hide();
            $(fd.field('CMSSubcategorii2').$parent.$el).hide();

        }
        /*     if (fd.field('CMSCategorii').widget.dataSource.data().length > 0) {
                 if (fd.field('CMSCategorii').value.LookupValue == 'Servicii la ATM') {
                     fd.field('CMSSubcategorii1').required = true
                 } else {
                     fd.field('CMSSubcategorii1').required = false
                 }
             }*/
    }
    // Calling hideOrShowDueDate when the user changes the Start Date
    fd.field('CMSCategorii').$on('change', hideOrShowProblem);
    fd.field('CMSSubcategorii1').$on('change', hideOrShowProblem2);

    // Calling hideOrShowDueDate on form loading
    hideOrShowProblem();
    hideOrShowProblem2();

});

One more in browser, and another dropdown field. shows default dropdown values.

@ixxxl,

So you need to change a dropdown field options, not just set field value, is that correct?

If so, you need to use this code:

var newOptions = fd.field('Lookup').value.Error

 fd.field('DropDown').widget.setDataSource({
            data: newOptions.map(function(i) { return i })
        });
1 Like

@Margo
Thank you!!! for now it works!!!

1 Like