Working with the TaxonomyClientService: Part 4 – Populating Values with the Lists web service

So far I’ve discussed how to get information about getting the types of taxonomy field, working with those fields, and how to get term sets. What about setting values on list items?

It isn’t immediately obvious how to do that. For a start, we wouldn’t actually be using the TaxonomyClientService. To set values on items, you use the Lists web service, using the UpdateListItems() method. This accepts XML describing the field and values.

But what fields do we submit, and what values? After all, as mentioned in part 1, there are two fields – one for the displayed value, and a hidden ‘notes’ field that contains the actual data!

There was no documentation about how to set these values, and limited and contradictory information in blog posts, so I investigated…

Continue reading “Working with the TaxonomyClientService: Part 4 – Populating Values with the Lists web service”

Advertisement
Working with the TaxonomyClientService: Part 4 – Populating Values with the Lists web service

Working with the TaxonomyClientService: Part 3 – Caching

In Part 2 of this series I described how to retrieve a TermSet, and interpret the results. I suggested using code:

string clientTimestamps = string.Format("<timeStamp>{0}</timeStamp>", lastClientCacheTime );
string clientVersion = "<version>1</version>";
string termStoreIds = string.Format("<termStoreId>{0}</termStoreId>", termStoreId.ToString("D"));
string termSetIds = string.Format("<termSetId>{0}</termSetId>", termSetId.ToString("D"));
string serverTermSetTimestampXml;
string result = _wssTax.GetTermSets(termStoreIds, termSetIds, 1033, clientTimestamps, clientVersion, out serverTermSetTimestampXml);

Fine, but what are these properties we’re passing into GetTermSets()? Continue reading “Working with the TaxonomyClientService: Part 3 – Caching”

Working with the TaxonomyClientService: Part 3 – Caching

Working with the TaxonomyClientService: Part 2 – Get the TermSet (and understand it!)

In Part 1 I looked at the structure of our Taxonomy field – which is in fact two fields. We also saw how the TaxonomyField definition has an array of properties related to it too. As a reminder, here’s a screenshot of the XML for it:

These properties are quite important, as they tell us what we need to know to get the correct TermSet for our field. Continue reading “Working with the TaxonomyClientService: Part 2 – Get the TermSet (and understand it!)”

Working with the TaxonomyClientService: Part 2 – Get the TermSet (and understand it!)

Working with the TaxonomyClientService: Part 1 – What fields are there?

I have been working on an integration that needs to read terms from SharePoint’s Managed Metadata service, for a particular field, and then populate that field with those values. All this has to be done via SharePoint’s web services – so the relevant ones here are the TaxonomyClientService, and Lists web service.

This has proved particularly bloody hard. Continue reading “Working with the TaxonomyClientService: Part 1 – What fields are there?”

Working with the TaxonomyClientService: Part 1 – What fields are there?

UpdateListItems Web Service fails when using item level permissions

This tip come from one of my colleagues, but it’s a good ‘un:
For those of you familiar with the Lists.asmx web service in SharePoint, you’ll know that the UpdateListItems() method allows you to apply metadata to a list item. The following XML provides a simple example of how I’ve been using it so far….
<Method ID='1' Cmd='Update'>
<Field Name='ID' />
<Field Name='FileRef'>http://site/library/folder1/folder2/mydoc.pdf</Field>
<Field Name='ContentType'>Invoice</Field>
<Field Name='InvoiceNumber'>12345</Field>
</Method>
Under normal circumstances, the above XML works just fine. However, if you enable fine grained permissions [Item Level Permissions] in a document library it will break with a permissions related error (even though you have permissions to perform the action!) Continue reading “UpdateListItems Web Service fails when using item level permissions”
UpdateListItems Web Service fails when using item level permissions

SharePoint Web Services and UTC time fun and games

SharePoint is designed that people can use it from multiple time zones. For example, you might have offices in London, Paris and New York. 0700 hours in New York is not the same time as 0700 in Paris, as many transatlantic telephone calls will attest to. Further, many nations have a ‘summer’ and ‘winter’ time, which seems to have been introduced to annoy dairy farmers and computer programmers.

Thus, SharePoint needs a common way to store these times. It does this using UTC time (Coordinated Universal Time). This is, near enough, GMT, and it’s also called Zulu by pilots, the military, and pedants. 0700Z (the Z represents ‘Zulu’ as in ISO8601) is the same time whether you’re in London or Sydney – just in Sydney, 0700 Zulu is actually in the evening.

Now, you don’t need to worry about this, ‘cos SharePoint is smart enough to translate your local time to UTC when you set a date and time, and to translate it back again when displaying the date to you. Thus, 0700 in New York would be stored as 1100Z in the SharePoint database, and then when you looked at that document’s properties, it would be converted back to 0700. If you looked at the document in, say, London, it would convert 1100Z to 1200. (Well, all this is as happens today – summer/winter time makes things really hairy).

So where am I going with this? I have an application where you fill in a date and time, and submit it to SharePoint. When I get the dates back, though, the time is out by an hour. I’m in the UK and it’s summertime, so my timezone is actually UTC+1; therefore, time conversions seem likely to be the issue. Continue reading “SharePoint Web Services and UTC time fun and games”

SharePoint Web Services and UTC time fun and games

Interference between SharePoint ItemEventReceivers and Web Services

So, I’ve been working on an application that uploads documents to SharePoint and sets metadata on the item via web services. I’ve made a note about how to do this before – although I’ve yet to vent my frustration at not having a web service call to upload a document in a single transaction that either fails or succeeds. Anyway, the result is that I have to upload the file and then set the metadata against it. Unfortunately, this wasn’t working for one of our customers – sometimes it would work, and sometimes it wouldn’t set the metadata. Continue reading “Interference between SharePoint ItemEventReceivers and Web Services”

Interference between SharePoint ItemEventReceivers and Web Services

Browse Directories Permission and Webs.GetWebCollection strangeness

I’ve had a support call from a client; an application that I’d written wasn’t letting some users see the subsites of a particular site. However, in the web browser, they could see (and navigate) to those sites. “Strange”, I thought, “they must’ve misconfigured their permissions”. Well, they hadn’t. Continue reading “Browse Directories Permission and Webs.GetWebCollection strangeness”

Browse Directories Permission and Webs.GetWebCollection strangeness

Why I was getting duplicate rows from the SharePoint Lists Web service

A couple of months ago I was making some calls to the SharePoint Lists Web Service, and I found that I was getting the same item back multiple times. This puzzled me – I mean, it was clearly by design, but why would anyone want a copy of the item for each value selected in a multiple-selection lookup?

It hit me last weekend (like a bolt from the blue) – you could use this to support Group By clauses on queries on a list. Yes, I know, SharePoint itself doesn’t support this functionality, but you could use the behaviour that I’d seen to support this. It’s the only explanation I’ve found that makes sense.

Now, can you turn off this behaviour, so you only get one item. That would be a lot more useful for what I was trying to do, although I now get why you might want that behaviour. Well, I don’t see a query option for it in the documentation, and cracking the service open in Lutz Reflector doesn’t show an option for it either.

I guess we’ll just have to accept the GetListItems command in the Web service API supporting Group By functionality, while SharePoint’s user interface itself does not. It’s a bit weird though that there isn’t an option I can find to turn it off though, and the Object Model behaves quite differently – it only returns one ListItem, and is unaffected by the multi-select lookup.

Why I was getting duplicate rows from the SharePoint Lists Web service

The circular logic of the WSS Lists Webservice GetListContentTypes call

So, I need to get a list of the content types applied to a library. The Lists webservice has a call for this:

<getlistcontenttypes xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listname>string</listname>
<contenttypeid>string</contenttypeid>
</getlistcontenttypes>

So, I’m connected to a site, I supply a list name to identify the list… …but what do I give as a contentTypeId? I don’t have a f$%king clue – I was calling this function to try to find out what content types were valid!

Well, good news. It doesn’t seem to matter what you put in, you always get a list of all the content types on the list. I used the following code…

WS_Lists.Lists lsts = new WS_TestApp.WS_Lists.Lists();
lsts.Credentials = System.Net.CredentialCache.DefaultCredentials;
XmlNode node = lsts.GetListContentTypes(libraryName, contentTypeID);

I figured that maybe they wanted the base content type for what I wanted back, so I tried setting contentTypeID to documents (0x0101) and got back a list of all the content types. I then set contentTypeID to “fish”, and still got back a list of all the content types. As far as I can tell, the second parameter doesn’t do anything.

Side note: The first content type returned is your default content type.

Side note 2: There doesn’t seem to be an easy way of identifying non-visible content types…

The circular logic of the WSS Lists Webservice GetListContentTypes call