Reputation: 13
How to set values to a multi choice field using SPServices in SharePoint ?
This Code worked
$().SPServices({
operation: "UpdateListItems",
async: false,
batchCmd: "Update",
listName: "Projets",
ID: 53,
valuepairs: [
["ProjectName", "Project"],
["ProjectType", "OPPS"],
["ConcernedServices", JSON.stringify($('#select-multiple-optgroups').val())],
["Cible", "Résidentiel"],
["DateRFF", "2014-12-31"],
["DateLancementPrevisionnelle", "2014-12-31"],
["DateDeFin", "2014-12-31"],
["Priorite", "PA"],
["Concept", "dfsf"],
["Reference", "FDF"],
],
completefunc: function (xData, Status) {
}});
But if I want to add multiple choice doesn't work
$().SPServices({
operation: "UpdateListItems",
async: false,
batchCmd: "Update",
webURL: "/sites/ep/",
listName: "Projets",
ID: 53,
valuepairs: [
["ProjectName", "Project"],
["ProjectType", "OPPS"],
["ConcernedServices", JSON.stringify($('#select-multiple-optgroups').val())],
["Cible", "Résidentiel, Business"],
["DateRFF", "2014-12-31"],
["DateLancementPrevisionnelle", "2014-12-31"],
["DateDeFin", "2014-12-31"],
["Priorite", "PA"],
["Concept", "dfsf"],
["Reference", "FDF"],
],
completefunc: function (xData, Status) {
}});
Cible is a Multiple Choice field in a sharepoint List.
Upvotes: 0
Views: 2482
Reputation: 47
I came across this post while trying to achieve the same thing, however this answer didn't work for me. I was eventually able to save multiple values in the lookup field using the following format:
"6;#;#8;#"
Where the numbers are the ID of the list items (to save formatting issues)
With the ID and the title of the list item it looked like this:
"6;#Alcohol:Reports;#4;#Alcohol: News"
Both of these methods successfully inserted the values into the list.
Upvotes: 1
Reputation: 3282
Since SPServices is calling the OOB webservices behind the scenes, in theory the standard means of updating multiple choice values should come into play: Delimit the values with ;#
E.g.
";#Résidentiel;#Business;#"
Note: Order matters. Make sure values are specified in the same order they're defined in the column
Upvotes: 1