I have a Multi select Look up column which as you all know is a control with two list boxes and "Add or Remove" Buttons.

The user populates the right-hand side of the control with some values by clicking the Add button; I have saved those selected values into array. Now the user changes an option in a cascading dropdown which actually populates this multi select lookup column.

Normally in this scenario, the default values are loaded into the left-hand side of the look up with the right-hand "Responsibility selected values" being blank. What I want to do is to load the right-hand listbox with the values stored in array.

I am open to a solution which is based on both jQuery and JavaScript Client Object Model. I haven't been successful so far. :( Please help.

 var newarry = new Array();
 $("[title='System']").change(function() {
     var responsibilityval = "";
     if (newarry.length > 0) {
         $.each(newarry, function(i) {
             if (newarry[i] != '') {
                 var mySelect = $("[title='Unit']");
                 mySelect.prepend("<option value='0'>Before Apples</option>");

I tried other options like but it didn't work

var mySelect = $("[title='Unit']");

Javascript object model sample

 function getWebSiteData() {
     clientContext = new SP.ClientContext.get_current();
     if (this.clientContext != undefined && clientContext != null) {

         var webSite = clientContext.get_web();
         oList = webSite.get_lists().getByTitle("Add New User");
         $.urlParam = function(name) {
             var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
             return results[1] || 0;
         var itemid = parseInt($.urlParam('ID'));
         oListItem = oList.getItemById(itemid);
         var listinfo = new SP.ListItemCreationInformation();
         var item = oList.addItem(listinfo);
         var fields = ['Responsibility'];
         $(fields).each(function() {
             var fieldName = this;
             var field = $("#" + fieldName);
             var fieldValue = field.val();
             var entries = [];
             var newitem = new SP.FieldLookupValue();

             item.set_item(fieldName, entries);

         clientContext.executeQueryAsync(Function.createDelegate(this, this.success), Function.createDelegate(this, this.failed));

 function success(sender, args) {

 function failed(sender, args) {
     alert("failed. Message:" + args.get_message());

I use this function to set multi-select lookups

//Sets the default value(s) of a multi-select lookup
function SetMultiSelectLookup(fieldName, values)
    $.each(values, function(){
        $("select[title='" + fieldName + " possible values'] option:contains(" + this + ")")
                .appendTo($("select[title='" + fieldName + " selected values']"));
    return false;   

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.