Setting value for dropdown list

Hi Plumsail!

      function populateDepartmentCodes(){

          //specify your site URL
          var siteURL = 'https://sitename.sharepoint.com/sites/Main/';
          let web = new Web(siteURL);

          web.lists.getByTitle('Department Codes').items.select('Title').get().then(function(items) {

              fd.field('DropDown1').widget.setDataSource({
                  data: items.map(function(i) { return i.Title + ' plus added data ' })
              });

              //set the dropdown with the previously selected value
              fd.field('DropDown1').value = fd.field('DepartmentCode').value;
          });
      }

      fd.spRendered(function() {

          //call function on from load
          populateDepartmentCodes();

          //fill SharePoint field with the selected value
          fd.field('DropDown1').$on('change', function() {
              fd.field('DepartmentCode').value = fd.field("DropDown1").value;
          });
      });

For this, is there a way where the data displayed is not going to be saved, bec as you can see, there is an added data to the dropdown and would not be exisitng in 'DepartmentCode' field?

              fd.field('DropDown1').widget.setDataSource({
                  data: items.map(function(i) { return i.Title + ' plus added data ' })
              });

Hello @Jes_Santimosa,

Not sure I understood your question. You want to populate the drop down with data, but don't want to save the field value. Is that correct?

Could you share a use case so that I can suggest a better solution.

Hello,
I have two dropdown, DepartmentCode from sharepoint and DropDown1 control field.
I want to display data from DepartmentCode with additional info on display and will be save back to DepartmentCode field so DropDown1 was created:

data: items.map(function(i) { return i.Title + ' plus added data ' })

' plus added data ' is hardcoded data for display only and should not be save.

My problem is to know how to save the data back to DepartmentCode dropdown sharepoint field from DropDown1, also, i.Title is not even a unique data.

@Jes_Santimosa,

Thank you for the details!

I would suggest using the SharePoint lookup field instead of a Drop Down. You can customize the search results appearance as you need.

If the source list is in another site, Plumsail Forms v1.8.7 has a Lookup control that connects list in different sites and even site collections.