Sharepoint batch for MultiChoice field value insertion - web-services

So i have a problem regarding usage of sharepoint list webservices.
I need to get the syntax right for Sharepoint batch script for insertion of new items.
Everyhing works fine except multichoice field type.
I insert the data, but nomatter how i do it, it shows up on SP list item details OK, but when trying to edit item in SP, i see, that SP have taken the value i sent to this field as text string, and does not check the items i have saved as selected.
The script for now is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<Batch OnError="Return">
<Method ID='1' Cmd='New'>
<Field Name='SecurityCheckpoints'>1st checkpoint;2nd checkpoint</Field>
</Method>
</Batch>
Definition for that field is like this:
<Field Type="MultiChoice"
DisplayName="Checkpoints allowed"
Required="TRUE"
FillInChoice="FALSE"
ID="{guid-guid-guid-guid-guid}"
SourceID="{guid-guid-guid-guid-guid}"
StaticName="SecurityCheckpoints"
Name="SecurityCheckpoints"
ColName="ntext2"
RowOrdinal="0"
Version="4">
<CHOICES>
<CHOICE>1st checkpoint</CHOICE>
<CHOICE>2nd checkpoint</CHOICE>
<CHOICE>3rd checkpoint</CHOICE>
</CHOICES>
<Default>1st checkpoint</Default>
</Field>
I have to implement something like custom UI for sharepoint in different-purpouse silverlight app, and so i am using my own webservice to be a proxy between SP and SL, i retrieve SP list definition and dinamicaly build UI controls, so user can fill in the forms.
How do i form the script, so items are selected(ticked) in the SP instead of SP saving them as just string value?
If I use script with only one item ("1st checkpoint"), SP processes it ok, it there is many, data is saved as text string?
What i am doing wrong? How do i correctly seperate multiple values?
I have searched high and low, but have not found example of SP update script, where multichoice sample is included.
Thank You in advance!

I found the sollution - it was too easy:
instead of seperating the choice values using semicolon ";", they had to be seperated using ";#", and putting it in front and in behind the whole list.
So rather than using this:
1st checkpoint;2nd checkpoint
<?xml version="1.0" encoding="UTF-8"?>
<Batch OnError="Return">
<Method ID='1' Cmd='New'>
<Field Name='SecurityCheckpoints'>1st checkpoint;2nd checkpoint</Field>
</Method>
</Batch>
It had to be done like this:
;#1st checkpoint;#2nd checkpoint;#
<?xml version="1.0" encoding="UTF-8"?>
<Batch OnError="Return">
<Method ID='1' Cmd='New'>
<Field Name='SecurityCheckpoints'>;#1st checkpoint;#2nd checkpoint;#</Field>
</Method>
</Batch>
PS:I dont know was it correct way to do this, but I answered my own question. Just for others to know.

I run code below successfully.
<?xml version="1.0" encoding="UTF-8"?><ows:Batch OnError="Return">
<Method ID="0"><SetList>3933c528-5747-4fc7-bdec-6465294997dd</SetList>
<SetVar Name="Cmd">Save</SetVar>
<SetVar Name="ID">New</SetVar>
<SetVar Name="urn:schemas-microsoft-com:office:office#Temp_UNID">8D8DE35CFFE9EEEAC12570920052A8FD</SetVar>
<SetVar Name="urn:schemas-microsoft-com:office:office#Title"> - Birch Data Exchange Specification</SetVar>
<SetVar Name="urn:schemas-microsoft-com:office:office#C0370A_Agora_DocNum">8AL020210178ZZASB</SetVar>
<SetVar Name="urn:schemas-microsoft-com:office:office#C0370A_Agora_Phase"></SetVar>
<SetVar Name="urn:schemas-microsoft-com:office:office#C0370A_Agora_Author">Jerome BOURGER</SetVar>
<SetVar Name="urn:schemas-microsoft-com:office:office#C0370A_Agora_ServicesOri"> </SetVar>
<SetVar Name="urn:schemas-microsoft-com:office:office#C0370A_Agora_Type">;#3 - Quality Plan;#Objectives;#Progress Plan;#Follow-up;#Reports;#</SetVar>
<SetVar Name="urn:schemas-microsoft-com:office:office#C0370A_Agora_Keywords"></SetVar> </Method></ows:Batch>

Related

XSLT - select a node from a complex xml file

I have an XML file below where I need to get the text inside of the <Description> tag under the <Checklist> tag where the <Sequence> tag has the text 40. How to achieve it?
<?xml version="1.0" encoding="UTF-8"?>
<SyncMaintenanceOrder>
<DataArea>
<MaintenanceOrder>
<MaintenanceOrderHeader>
<DocumentID>
<ID accountingEntity="AT">1105442</ID>
</DocumentID>
<Description>Routine Bridge Inspection - S6</Description>
<PriorityCode>2</PriorityCode>
<ReportedDateTime>2020-04-29T20:21:27Z</ReportedDateTime>
</MaintenanceOrderHeader>
<MaintenanceOrderLine>
<LineNumber>10</LineNumber>
<RemainingDuration>PT8H0M0S</RemainingDuration>
<ActivityDeferredIndicator>false</ActivityDeferredIndicator>
<UserArea>
<EamCheckListInfo>
<CheckList>
<CheckListItem>
<Sequence>40</Sequence>
<Description>Half joints (Superstructure elements)</Description>
</CheckListItem>
<CheckListItem>
<Sequence>160</Sequence>
<Description>Substructure drainage (Durability elements)</Description>
</CheckListItem>
<CheckListItem>
<Sequence>60</Sequence>
<Description>Parapet beam or cantilever (Superstructure elements)</Description>
</CheckListItem>
</CheckList>
</EamCheckListInfo>
</UserArea>
</MaintenanceOrderLine>
</MaintenanceOrder>
</DataArea>
</SyncMaintenanceOrder>
I need sample of an XSLT code for selecting only the text node described above.
I'm not sure I really get your question.
This will print the Description of the CheckListItem which has a Sequence of 40:
<xsl:value-of select="//CheckListItem/Sequence[text()='40']/../Description"/>
Try it here: https://xsltfiddle.liberty-development.net/ehVZvvZ
Try the below code
<xsl:value-of select="*[local-name(.)='SyncMaintenanceOrder']/*[local-name(.)='DataArea']/*[local-name(.)='MaintenanceOrder']/*[local-name(.)='MaintenanceOrderLine']/*[local-name(.)='UserArea']/*[local-name(.)='EamCheckListInfo']/*[local-name(.)='CheckList']/*[local-name(.)='CheckListItem']/*[local-name(.)='Sequence'][text() = '40']/../*[local-name(.)='Description']" />

Reporting Services, how to query a webservice with complex type parameter as input

I need to query a webservice passing complex parameters in Reporting Services as input.
How can I do this?
In Query Designer at Visual Studio, I'm doing the query like this :
<Query>
<SoapAction>http://mywebservice.com/Customers/GetCustomers</SoapAction>
<Method Name="GetCustomers" Namespace="http://mywebservice.com/Customers/">
<Parameters>
<Parameter Name="myParams" type="xml">
<DefaultValue>
<myParams>
<IdCustomer>0</IdCustomer>
</myParams>
</DefaultValue>
</Parameter>
</Parameters>
</Method>
<ElementPath IgnoreNamespaces="true">*</ElementPath>
</Query>
WebService expect it as parameter:
<?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>
<GetCustomer xmlns="http://mywebservice.com/Customers/">
<myParams>
<IdCustomer>int</IdCustomer>
<IdCustomer>int</IdCustomer>
</myParams>
</GetCustomer>
</soap:Body>
</soap:Envelope>
When I try it at Visual Studio 2008, I get this error message :
Failed to execute web request for the specified URL. Soap Fault:
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object.
You should look at the xml being sent in a test client in order to get an example of the syntax needed for your query. I recommend using the wcftestclient that comes with Visual Studio. Once you run a test, you can view the xml on the XML tab (at the bottom of the screen in wcftestclient), and replace what is in the <DefaultValue> section of your query with the corresponding parameter values.
The query for that webservice should look something like the following. Note the a namespace which will be depend on your own situation:
<Query>
<SoapAction>http://mywebservice.com/Customers/GetCustomers</SoapAction>
<Method Name="GetCustomer" Namespace="http://mywebservice.com/Customers/">
<Parameters>
<Parameter Name="myParams" type="xml">
<DefaultValue xmlns:a="http://schemas.datacontract.org/2004/07/MyWebServices">
<a:IdCustomer>0</a:IdCustomer>
<a:IdCustomer>1</a:IdCustomer>
</DefaultValue>
</Parameter>
</Parameters>
</Method>
</Query>
Also, I do see that you have <Parameter type="xml">. For Me, I spent hours working through a similar query and was missing the type="xml". That attribute does not seem to be well documented on MSDN.

Using SharePoint's lists.asmx and UpdateListItems to delete an item by Guid or UniqueId

I am trying to call the lists.asmx UpdateListItems() to delete a list item by unique id or guid. The following batch xml fails with "Invalid URL Parameter. The URL provided contains an invalid Command or Value. Please check the URL again".
<Batch OnError="Continue" ListVersion="1" ViewName="">
<Method ID="1" Cmd="Delete">
<Field Name="Guid">7be4a863ce-08de-4506-9c69-400749860e76</Field>
</Method>
</Batch>
In addition, I have tried with and without enclosing "{}", UrlEncoding, using UniqueId instead of Guid, prefixing the guid with "[id];#", etc. but to no avail.
Using the ID will work, but I would prefer using the Guid if possible:
<Batch OnError="Continue" ListVersion="1" ViewName="">
<Method ID="1" Cmd="Delete">
<Field Name="ID">29</Field>
</Method>
</Batch>
Anyone have any ideas, or is this not possible using the UniqueID or Guid?
From the documentation, they only give an example using ID... which leads me to believe it probably will not work with anything else.

Translating itunes affiliate rss via xslt

I can't get this working for the life of me. Here is a snippet of the xml I get from an RSS feed from itunes affiliate. I want top print the values within tags but I cannot for some reason:
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns:im="http://itunes.apple.com/rss" xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
<id>http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/toppaidapplications/sf=143441/limit=100/genre=6014/xml</id><title>iTunes Store: Top Paid Applications</title><updated>2010-03-24T15:36:42-07:00</updated><link rel="alternate" type="text/html" href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewTop?id=25180&popId=30"/><link rel="self" href="http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/toppaidapplications/sf=143441/limit=100/genre=6014/xml"/><icon>http://phobos.apple.com/favicon.ico</icon><author><name>iTunes Store</name><uri>http://www.apple.com/itunes/</uri></author><rights>Copyright 2008 Apple Inc.</rights>
<entry>
<updated>date</updated>
<id>someID</id>
<title>a</title>
<im:name>b</im:name>
</entry>
<entry>
<updated>date2/updated>
<id>someID2</id>
<title>a2</title>
<im:name>b2</im:name>
</entry>
</feed>
If I try <xsl:apply-templates match="entry"/> it spits out the entire contents of file. If I use <xsl:call-template name="entry"> it will show only one entry and I have to use <xsl:value-of select="//*[local-name(.)='name']"/> to get name but that's a hack. I've used xslt before for xml without namespaces and xml that has proper parent child relationships but not like this RSS feed. Notice entry is not wrapped in entries or anything.
Any help is appreciated. I want to use xslt because I want to alter the itunes link to go through my affiliate account - so something automated wouldn't work for me.
You are matching elements that are in no namespace, but the actual elements in the XML document do belong to a (deafult) namspace: xmlns="http://www.w3.org/2005/Atom".
Therefore, you need to declare the namespace in your stylesheet, let's say xmlns:atom="http://www.w3.org/2005/Atom". and then match not just on {elementName} but on {atom:elementName}, where {elementName} in your case is: "entry".

How do I rename a file using the SharePoint web services?

I have a custom definition for a document library and I am trying to rename documents within the library using only the out of the box web services. Having defined a view with the "Name" field supplied and trying the "LinkFilename", my calls to rename a file are respectively returning a failure or ignoring the new value.
How do I rename a file using the SharePoint web services?
Use the Lists.UpdateListItems web method. The XML request should look like:
<Batch OnError="Continue" PreCalc="TRUE" ListVersion="0">
<Method ID="1" Cmd="Update">
<!-- List item ID of document -->
<Field Name="ID">2</Field>
<!-- Full URL to document -->
<Field Name="FileRef">http://Server/FullUrl/File.doc</Field>
<!-- New filename -->
<Field Name="BaseName">NewName</Field>
</Method>
</Batch>
You should be able to use UpdateListItems. Here's an example.
Per comment: So the actual question is "how do I call a web service?" Take a look a this example. Some more good walkthroughs here.