This project has moved. For the latest updates, please go here.

Can't set a Drop Down Choice Field using UpdateListItems

Mar 27, 2013 at 1:50 PM
Hi Marc...

Ever since your class on SPServices, I have been using it and loving it. However, I have recently hit a conundrum. I am running SharePoint 2013. I am creating new list items using the UpdateListItems web service. Everything is working fine...except when I try to set the Choice field.

I have tried many variations, but it either displays unwanted ";#" text in AllItems or DispForm and in EditForm it is always Blank. This is a Single Choice Field...not a Multi.

How should one format the value being used to set a Choice Field?

function CreateNewWorkOrder(prop, name, place) {
// Trying to determine the right format for a CHOICE field - and None seem to work
// var myPlace = place;  // A Simple String  such as 'Boston' from a Choice field
// var myPlace = ";#" + place;
// var myPlace = ";#" + place + ";#";
// var myPlace = place + ";#";      
// var myPlace = place + ";#" + place;

        operation: "UpdateListItems",
        async: false,
        batchCmd: "New",
        listName: "Work Order",
        valuepairs: [["Property", prop], ["Facility", myPlace], ["Title",name]],
        completefunc: function(xData, Status) {
Mar 27, 2013 at 2:50 PM
I just tested with a Choice column - I rarely use them, preferring to use Lookup columns instead - and it's a simple matter of setting to the value you want. My column is StateColor with choices [Red | Blue | Neutral]. Here's my test script:
    operation: "UpdateListItems",
    async: false,
    listName: "States",
    ID: 264,
    valuepairs: [["StateColor", "Red"]],
    completefunc: function (xData, Status) {
Mar 27, 2013 at 3:39 PM

Thanks for your FAST reply. As usual...PEBKAC [problem exists between keyboard and chair].

the issue was simply that the manner in which I was getting the value from the DOM was adding spaces. Once I used a different method and/or trimmed the value...success. Sorry to have wasted your time...but maybe a warning to others...using Alerts will not necessarily reveal hidden spaces in your variables...and that is what sunk this ship.

Thanks again for your comittment to the community and the great tools you have given to us.

Mar 27, 2013 at 3:42 PM

No worries. That kind of thing is why getting familiar with the in-browser debugging techniques is important. That, and I always enclose my values in "::" in alerts. ;+)