I have 2 multi-select picklists and I want to: 1. Add all the values selected in Picklist1 to Picklist2 2. Remove the selected values from Picklist1 after they are added to Picklist2

While, I am able to achieve the 1st requirement. How to achieve the 2nd requirement.

  • What did you try so far?
    – Reshma
    Commented Mar 20, 2017 at 9:39
  • I tried using selectedIndex and Picklist2[options] as used in javascript for picklists. But, these values come out to be "undefined" Commented Mar 20, 2017 at 9:40
  • Any idea how can I get the indices of selected elements of a multi-select picklist? Commented Mar 20, 2017 at 9:45
  • Can you post the corresponding code also?
    – Reshma
    Commented Mar 20, 2017 at 9:47

1 Answer 1


Ok, so assuming you have just completed step 1, you have a large list in picklist 1 and a smaller list in picklist two.

I'm also assuming that you are using databinding in lightning are are not directly manipulating the DOM

Given these conditions, run your first list through this function. It will remove any dupe values already in the second list:

xorSourceItems : function(source,dest) {
  var itemsToReturn = [];
  source.forEach(function(sourceItem, sourceIndex) {
    var match = false;
    dest.forEach(function(destItem, destIndex) {
      if (destItem.value == sourceItem.value) {
        match = true;
    if (!match){
  return itemsToReturn;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .