The SharePoint list that is enabled for approval, if we modify one of the approved list items through the object model, the update causes the list item to return to the pending state. However, the object model has a strong systemupdate, can be quietly modify the list items. However, if you are making changes through the Lists.asmx updatelistitems in the SharePoint Web service, you are not so lucky.
Referencing the description in the SharePoint SDK: the Cmd property of each method element determines what action is performed on the project by specifying one of the following values:
*delete--Deletes an item.
*new--Creates an item.
*update--modifies the item.
For what we said above, CMD can only write "Update".
The common wording on the Web is as follows:
1 <Batch OnError="Continue">
2 <Method ID="1" Cmd="Update">
3 <FIEld Name="ID">3634</Field>
4 <Field Name="FileRef">3634;#Lists/Fichesroyjs/3634_.000</Field>
5 <Field Name="_ModerationStatus">0</Field>
6 </Method>
7 </Batch>
Modify the approval status of a document library (invalid)
However, the results of this operation are always pending. Even the <field name= "_moderationstatus" >0</Field> is included in the update. Perhaps you will think of the update two times, here can directly tell you the results, or to be determined.
So how do you add or modify list items and ensure approval status is approved?
The answer was finally found on the forum. When you perform approval through a Web service, you should use the "moderate" command instead of the "Update" command.
The wording is as follows:
1 <Batch>
2 <Method ID='1' Cmd='<strong>Moderate</strong>'>
3 <Field Name='ID'>6</Field>
4 <Field Name='<strong>_ModerationStatus</strong>'>0</Field> ;
5 </Method>
6 </Batch>
Modify the approval status of a list item with ID 6 in a list as approved
Attached below is a complete list of updates and automatically approves the example. One of the most important is the cmd= "moderate" sentence:
01 public static XmlNode UpdateListItemApprove()
02 {
03 listservice.Lists listProxy = new listservice.Lists();
04 string xml = "<Batch OnError='Continue'><Method ID='1' Cmd='Moderate'><FIEld Name='ID'>167</Field><Field Name='PublishToHomePage' Type='Boolean'>1</Field><Field Name=\"_ModerationStatus\" >0</Field></Method></Batch>";
05 XmlDocument doc = new XmlDocument();
06 doc.LoadXml(xml);
07 XmlNode batchNode = doc.SelectSingleNode("//Batch");
08 listProxy.Url = "http://puremoss/it/_vti_bin/lists.asmx";
09 listProxy.UseDefaultCredentials = true;
10 XmlNode resultNode = listProxy.UpdateListItems("通知", batchNode);
11 return resultNode;
12 }