cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
esemuhdeoh
Nintex Newbie

Get ID when creating item with lists.asmx

Hello,

when using the "create item"-action I have the option the get the ID of the element that I am creating. This allows me to set a "set item permission" on exactly this element that I created.

I need to use the web service "lists.asmx" to create the item, but I don't know if there is a way to get the ID of the created element.

Can you help?

0 Kudos
Reply
3 Replies
Nintex Employee
Nintex Employee

Re: Get ID when creating item with lists.asmx

Hi Christian,

When you create a new list item using the UpdateListItems method, the response content should contain the XML node for the updated rows (including the item ID).  You should be able parse out the ID out from that response content using a query XML action and/or a Regular Expression action.

This MSDN article should provide more context for what is returned.

0 Kudos
Reply
esemuhdeoh
Nintex Newbie

Re: Get ID when creating item with lists.asmx

Thanks Dan,

if I had put in a little bit more effort I would have found it.

So now I am starting the web service "lists.asmx" with the following code:

<?xml version="1.0" encoding="utf-8"?>

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:m="http://schemas.microsoft.com/sharepoint/soap/">

  <soap:Header>

  </soap:Header>

  <soap:Body>

    <m:UpdateListItems>

      <m:listName>listname</m:listName>

      <m:updates>

  <Batch RootFolder="/sites/SiteCollectionName/listname/parentfolder/childfolder">

   <Method ID="1" Cmd="New">

    <Field Name="ID">New</Field>

    <Field Name="FSObjType">1</Field>

    <Field Name="BaseName">namefornewchildfolder</Field>

   </Method>

  </Batch>

      </m:updates>

    </m:UpdateListItems>

  </soap:Body>

</soap:Envelope>

Then I am using the Query-XML-action to get the ID with "//z:row/ows_ID".

That will give me the correct ID.

Thanks a lot

0 Kudos
Reply
Automation Master
Automation Master

Re: Get ID when creating item with lists.asmx

The XPath Expression should rather be "//z:row/@ows_ID" as this is the syntax to get the value of the "ows_ID" attribute. Select "inner Text" in xml query action.

0 Kudos
Reply