lookup multi field won't save its value

Coordinator
Jan 26, 2010 at 1:53 PM
Edited Jan 26, 2010 at 2:19 PM
Hi,

I'm getting this strange behaviour:
I can set the value of a multi lookup field but the value is not saved..

this is what I did to reproduce the bug:
1) create a custom list named list3 and add a couple of items
2) create a custom list named list1 and add a lookup multi column named "LookupMulti"
3) create an item in list1 (with the lookup item set)
4) create a custom list named list2 and add a lookup multi column named "LookupMulti" (same as list1)
5) add Form Web Part in list2/NewForm.aspx and use this code:

$(document).ready( function ()
{
var siteurl = "http://localhost/test/"; // this is my site name
var listname = "list1"; // copy the lookup value from the first element of list1
jP.Form.readForm();
var tmpView = jP.Lists.setSPObject(siteurl, listname).getSPView();
var selectedItem = tmpView.Items[0];
jP.Form.LookupMulti.val(selectedItem["LookupMulti"]);
});



the NewForm.aspx works as expected: I can see LookupMulti set as expected, but when I save the item LookupMulti is not saved.

Best Regards,
Davide.

Comments
dmorelli wrote Fri at 10:55 AM<abbr></abbr>
Also, setting a single lookup field value doesn't work at all:
if I create a Looup field (with multiple values not allowed) this code doesn't work at all:

jP.Form.LookupSingle.val(selectedItem["LookupSingle"]);

I get the same problem with a Choice - Checkboxes field (doesn't work at all).

samirsijercic wrote Fri at 11:47 AM<abbr></abbr>
Hi Davide,
Could you please let me know what browser you are running?
You are trying to set values of fields through jPoint and use Sharepoints "Save" to save a list item?
I will check into fields requested and get back to you with solution.

dmorelli wrote Fri at 5:48 PM<abbr></abbr>
Sorry I forgot to write the browser..
it's IE 7 and Firefox 3 on Windows 2003 running in a Virtual Machine (Virtual box).

Yes, I'm trying to set fields values through jPoint and then save them using the "save" button.

thankyou!

ken_le wrote Sun at 11:49 PM<abbr></abbr>
There's a hidden field currently not set using this method. To fix this, add the following to you code.

$(document).ready( function ()
{
var siteurl = "http://localhost/test/"; // this is my site name
var listname = "list1"; // copy the lookup value from the first element of list1
jP.Form.readForm();
var tmpView = jP.Lists.setSPObject(siteurl, listname).getSPView();
var selectedItem = tmpView.Items[0];
jP.Form.LookupMulti.val(selectedItem["LookupMulti"]);

//Find and update hidden field with selection
var mlpHiddenInput = jP.Form.LookupMulti.find("input[id$='MultiLookupPicker']"); //find hidden field
var mlpID = mlpHiddenInput.attr("id") + "_m"; //get id and construct master object name
var mlpObj = eval(mlpID); //get master object for current field
GipSetHiddenControlValue(mlpObj); //use sharepoint function to update control

});

dmorelli wrote Mon at 5:17 AM<abbr></abbr>
Setting the hidden field works! you rock!

what about the lookup-single and choice-checkboxes? is it a known bug? let me know if you have a snippet of code to make them work, if not: I'll try to write something and I'll post it here.

Another bit of info I forgot to tell: I'm using WSS 3.0.

ken_le wrote Today at 9:34 AM<abbr></abbr>
single-lookup setter syntax ->
jP.Form.mysinglelookupfield.val("value1")
choice-checkboxes setter syntax ->
jP.Form.mychoicecheckboxfield.val("value1,value2,value3") //check specific checkboxes
jP.Form.mychoicecheckboxfield.val("[value1,value2,value3]") //check specific checkboxes
jP.Form.mychoicecheckboxfield.val("{value1,value2,value3}") //check specific checkboxes
jP.Form.mychoicecheckboxfield.val("") //uncheck all checkboxes jP.Form.mychoicecheckboxfield.val("1") //check all checkboxes


Following your example and you add a LookupSingle and ChoiceMulti fields, the code would be

var selectedItem = tmpView.Items[0];
//selectedItem["LookupSingle"] sample data --> "4;#ddd"
//take text value and set field
jP.Form.LookupSingle.val(selectedItem["LookupSingle"].split(";#")[1]); 

//selectedItem["ChoiceMulti"] sample data --> ";#222;#333;#444;#"
//format into comma delimited, chop off leading and trailing commas, set field
jP.Form.ChoiceMulti.val(selectedItem["ChoiceMulti"].replace(/;#/g,",").replace(/^,/,"").replace(/,$/,"")); 
Jan 26, 2010 at 2:55 PM

I confirm that you are right, everything works!

Aug 23, 2011 at 12:39 PM

I realise it's been a while since you posted this but I was hoping you could help me understand the function "GipSetHiddenControlValue" - I can't seem to find any documentation for it online at all! This is the only place Google has heard of it.