2

I am trying to use the UpdateListItems Web Service API call to create a new (customised) folder and set meta data at the same time. Here is my batch element:

    <Batch ListVersion="1" OnError="Continue" xmlns="">
       <Method Cmd="New" ID="1">
          <Field Name="ID">New</Field>
          <Field Name="FSObjType">1</Field>
          <Field Name="BaseName">Students A/AHN (AHCJD1001)</Field>
          <Field Name="ContentType">Student Folder</Field>
          <Field Name="StudentID">AHCJD1001</Field>
          <Field Name="Surname">AHN</Field>
          <Field Name="Status_x0020_Code">C</Field>
          <Field Name="Archived">1</Field>
       </Method>
    </Batch>

Now, it all works perfectly - EXCEPT the Archived field. That is a boolean field in SharePoint and nothing I do in this batch allows me to ever set it to true. All the other fields work fine, setting surname, student ID, content type and status code. I have tried using 1 and True as Archived values, neither works. It always ends up as "No" in SharePoint.

Any ideas?

Chris

  • 2
    Have you tried setting the value as "Yes"? – Bil Simser Apr 29 '11 at 1:34
  • Good idea. Tried with "Yes", "TRUE" and "True" - none work. All still leave Archived showing as "No" when using View Properties. – Chris KL Apr 29 '11 at 2:30
  • I have now discovered several other blog posts that imply it's supposed to just be '1': hemsoft.blogspot.com/2010/04/… and eggheadcafe.com/community/aspnet/69/10096994/… – Chris KL Apr 29 '11 at 2:51
  • Are you sure the field is Boolean? I have a vague memory of similar problem and I think the field ended up being some other type. – Paul Rowland Apr 29 '11 at 5:03
  • Site Settings says it's a "Yes/No (check box)" column. – Chris KL Apr 29 '11 at 6:16
2

I got really curious what the diagnosis is. I've double checked and for me such Batch works:

<?xml version=\"1.0\"?>
<Batch xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" OnError=\"Return\">
    <Method ID=\"1\" Cmd=\"New\">
        <Field Name=\"Title\">Test</Field>
        <Field Name=\"ID\">New</Field>
        <Field Name=\"Done\">TRUE</Field>
    </Method>
</Batch>

Works with "TRUE" and "True".

And what do you get in xml returned from UpdateListItems?
Mine (check ows_Done for the boolean column):

<Result ID="1,New"
xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<ErrorCode>0x00000000&lt;/ErrorCode>&lt;ID />
<z:row
ows_ContentTypeId="0x0100C27C8A4A9DD66247971ECA37E457EF11"
ows_Title="Test"
...
ows_ID="39"
ows_Done="1"

So I've checked with

<Field Name=\"Done\">1</Field>

and it works as well! :)

0

I recheck this issue and it works fine with my code snippet. What I did is, added one column Archived of type (Yes/No (check box)).

Take one boolean variable inside your code.

bool IsArchived = true;


<Batch ListVersion="1" OnError="Continue" xmlns="">
       <Method Cmd="New" ID="1">
          <Field Name="ID">New</Field>
          <Field Name="FSObjType">1</Field>
          <Field Name="BaseName">Students A/AHN (AHCJD1001)</Field>
          <Field Name="ContentType">Student Folder</Field>
          <Field Name="StudentID">AHCJD1001</Field>
          <Field Name="Surname">AHN</Field>
          <Field Name="Status_x0020_Code">C</Field>
          <Field Name="Archived">IsArchived</Field>
       </Method>
    </Batch>

This is what i did and it worked as expected.

  • What do you mean "Take one boolean variable inside your code."? – Chris KL May 4 '11 at 4:24
  • I had certain requirement to update field value using SharePoint web services. You can set your boolean variable and pass that value as shown above. – ashish.chotalia May 4 '11 at 5:05
0

I blogged about this here. The blog entry talks about the Content Query Web Part and does not use Web Services but I think in principle the issue is the same. Bottom line, use "1" for Yes and "0" for No.

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.