S
steve
I've been trying (most of the day) to add an item to a SharePoint
list, using the UpdateListItems web service.
First I read this article:
http://www.infopathdev.com/howto/tutorials/default.aspx?i=7bc880f391b84ea9b3b45c6fbecc07c6
Great! I was able to add an item the Contacts list no problem (well,
some problems, but i got it to work).
then i tried the same technique with an Events list. Not so great.
The Events list has dates, and I'm pretty sure that's what is causing
me problems. The dates are not in the correct format. the web service
returns an error, value not in expected range.
So, maybe I need to add some additional VB code to my Visual Studio
project to format the dates. Makes sense to me.
I read another article which explains just what to do. Great! I'm
rolling now! Except - it's in C#, which I know nothing about (even
less than i know about VB)
Next, I find a site that translates from C# to VB.NET. Seems to be
my lucky day.
http://www.kamalpatel.net/ConvertCSharp2VB.aspx
Great! But when i paste the results into Visual Studio, i get a
zillion compile errors. ?
is anybody still reading this?
Here's the original C# code.
XPathNavigator root = MainDataSource.CreateNavigator();
// Retrieve the values for the calendar item
string title = root.SelectSingleNode("my:myFields/my:title",
NamespaceManager).Value;
string location = root.SelectSingleNode("my:myFields/my:location",
NamespaceManager).Value;
string startDate = root.SelectSingleNode("my:myFields/my:startDate",
NamespaceManager).Value;
string startTime = root.SelectSingleNode("my:myFields/my:startTime",
NamespaceManager).Value;
string endDate = root.SelectSingleNode("my:myFields/my:endDate",
NamespaceManager).Value;
string endTime = root.SelectSingleNode("my:myFields/my:endTime",
NamespaceManager).Value;
XPathNavigator batch = DataSources["EventCAML"].CreateNavigator();
// Set the title
batch.SelectSingleNode("/Batch/Method/Field[@Name='Title']",
NamespaceManager).SetValue(title);
// Set the location
batch.SelectSingleNode("/Batch/Method/Field[@Name='Location']",
NamespaceManager).SetValue(location);
// Set the start date
batch.SelectSingleNode("/Batch/Method/Field[@Name='EventDate']",
NamespaceManager).SetValue(string.Format("{0}T{1}Z", startDate,
startTime));
// Set the end date
batch.SelectSingleNode("/Batch/Method/Field[@Name='EndDate']",
NamespaceManager).SetValue(string.Format("{0}T{1}Z", endDate,
endTime));
// Submit the item details to the web service to update the calendar
DataConnections["Web Service Submit"].Execute();
thanks!
list, using the UpdateListItems web service.
First I read this article:
http://www.infopathdev.com/howto/tutorials/default.aspx?i=7bc880f391b84ea9b3b45c6fbecc07c6
Great! I was able to add an item the Contacts list no problem (well,
some problems, but i got it to work).
then i tried the same technique with an Events list. Not so great.
The Events list has dates, and I'm pretty sure that's what is causing
me problems. The dates are not in the correct format. the web service
returns an error, value not in expected range.
So, maybe I need to add some additional VB code to my Visual Studio
project to format the dates. Makes sense to me.
I read another article which explains just what to do. Great! I'm
rolling now! Except - it's in C#, which I know nothing about (even
less than i know about VB)
Next, I find a site that translates from C# to VB.NET. Seems to be
my lucky day.
http://www.kamalpatel.net/ConvertCSharp2VB.aspx
Great! But when i paste the results into Visual Studio, i get a
zillion compile errors. ?
is anybody still reading this?
Here's the original C# code.
XPathNavigator root = MainDataSource.CreateNavigator();
// Retrieve the values for the calendar item
string title = root.SelectSingleNode("my:myFields/my:title",
NamespaceManager).Value;
string location = root.SelectSingleNode("my:myFields/my:location",
NamespaceManager).Value;
string startDate = root.SelectSingleNode("my:myFields/my:startDate",
NamespaceManager).Value;
string startTime = root.SelectSingleNode("my:myFields/my:startTime",
NamespaceManager).Value;
string endDate = root.SelectSingleNode("my:myFields/my:endDate",
NamespaceManager).Value;
string endTime = root.SelectSingleNode("my:myFields/my:endTime",
NamespaceManager).Value;
XPathNavigator batch = DataSources["EventCAML"].CreateNavigator();
// Set the title
batch.SelectSingleNode("/Batch/Method/Field[@Name='Title']",
NamespaceManager).SetValue(title);
// Set the location
batch.SelectSingleNode("/Batch/Method/Field[@Name='Location']",
NamespaceManager).SetValue(location);
// Set the start date
batch.SelectSingleNode("/Batch/Method/Field[@Name='EventDate']",
NamespaceManager).SetValue(string.Format("{0}T{1}Z", startDate,
startTime));
// Set the end date
batch.SelectSingleNode("/Batch/Method/Field[@Name='EndDate']",
NamespaceManager).SetValue(string.Format("{0}T{1}Z", endDate,
endTime));
// Submit the item details to the web service to update the calendar
DataConnections["Web Service Submit"].Execute();
thanks!