Sunday, January 22, 2012

Call web service from Nintex


Requirement: Copy a List item between site collections.

Oops! Nintex doesn't has any direct method to do that. It offers Copy/Move/Create list items with in Same site, but not between site collections. So, Lets seek help from Web services with Nintex.

Lets say, I've a Source-list and Target-List. What I want is: based on some conditions, copy the item from source list to target list. Here is the Nintex's part.
  1. Drop a Call web service action in Nintex workflow
             2. Get the web services from the target site, e.g: http://SharePoint-Site.com/_vti_bin/Lists.asmx, and then configure the action as per the below picture


    So, Look at the highlighted sections. Here you have to specify the GUID of the target list and supply the XML data for values.

 <Batch OnError="Continue">
     <Method ID="1" Cmd="New">
              <Field Name="Title"> {ItemProperty:Title} </Field>
               <Field Name="Salary"> {ItemProperty:Salary}</Field>
     </Method>
 </Batch>    


Here, the {ItemProperty:Title} and {ItemProperty:Salary} are fields inserted using Nintex "Insert Reference" button!

For the Update operation, we can use the same method, only  the CMD changes from NEW to UPDATE.

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
          <listName>my-List</listName>
            <updates>>
              <Batch OnError="continue" PreCalc="TRUE" ListVersion="0"> 
              <Method ID="1" Cmd="Update"> 
                <Field Name="ID">{ItemProperty:ParentID}</Field> 
               <Field Name="ApprovedinTargetList">No</Field> 
            </Method> 
        </Batch>
   </updates>
        </UpdateListItems>
    </soap:Body>
</soap:Envelope>

The Most important part here is: ID field, which maps our update operation with the particular list item.



2 comments:

  1. I was able to get the copy lis item going but Update does not seem to work

    ReplyDelete
    Replies
    1. Bhavneet,

      The above code posted from a working workflow. Compare your XML with the above provided XML on update section, Verify the ID of your existing List item.

      Delete

You might also like:

Related Posts Plugin for WordPress, Blogger...