Using Web Request To Create New List Item

  • 26 December 2018
  • 4 replies
  • 5 views

Badge +1

Hello,

I am trying to use the Web Request widget to create a line item and fill in multiple columns in a dynamic list (dynamic list because the list where content is added always changes).


Currently I am only able put information in the Title column of a dynamic list. I can't figure out how to format the XML code so that I can put information in multiple columns. My screen isn't large enough to screenshot everything, so the relevant values are below:

URL: Web_URL/_vti_bin/lists.asmx

SOAP 1.1 is being used

SOAP Action: http://schemas.microsoft.com/sharepoint/soap/UpdateListItems

XML Code:

<?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>SPECIFIED_LIST</listName>
<updates>
<Batch OnError="Continue">
<Method ID="1" Cmd="New">
<Field Name="Title">TITLE_VALUE</Field>
</Method>
</Batch>
</updates>
</UpdateListItems>
</soap:Body>
</soap:Envelope>

Using the configuration above, a new line item is added to a specified list. What I can't figure out is how to add items to more than one column.

Other details:

This workflow is tied to a form library.

All the lists getting content added to them are in the same site as this workflow.

The account being used is a Site Owner in SharePoint.

Any help is greatly appreciated.


4 replies

Badge +7

You should be able to simply add the additional fields one after another like so:

<Method ID="1" Cmd="New">
<Field Name="Title">TITLE_VALUE</Field>
<Field Name="ColumnA">VariableA</Field>
<Field Name="ColumnB">VariableB</Field>
<Field Name="ColumnC">VariableC</Field>
</Method>

However, the 'Name' attribute is looking for the system name of the column, not the display name.

To get the system name, go to the list/library settings page, click on the column, and look at the very end of the URL.

One key thing to note is that spaces are not really spaces. In SharePoint, a space is actually _x0020_ so, when I created a field called 'Text Box', the system name is actually 'Text_x0020_Box'.

Here's what you're looking for in the URL of the column: &Field=Text_x0020_Box

Additionally, there's a limit to the number of characters. This means with really long column names, the name will be truncated. You need to use the truncated system name. Whatever is after the '&Field=' is what you need to put in the 'Name' attribute.

Badge +1

Thank you, I was previously using the display name when using the format you gave.

Currently I have a column named "ExpectedCount" which has a system name of "ud3b". Will the system name for "ExpectedCount" ever change? All the lists being created are using the same template.

Badge +7

Without testing it, I do believe the column's system name will never change. However, you should definitely test this.

That's quite the odd system name for a column. I assume you have some third party application creating the columns. 

Did it work using the system name?

Badge +1

So far the system names for the columns have not changed.

Using the system names with the format you provided worked, thank you!

Reply