Adding meta data to a multiple choice field in a FrontPage RPC call
I was recently asked to find an easy way of moving multiple documents from a Domino database to a SharePoint site along with their respective meta data.
I promtly opted to use a FrontPage RPC call (FPRPC) instead of using any of the webservices or the client object-model due to possible memory restrictions on the server (I didn't know the size of the documents) and because FPRPC supports sending meta data along with the document at the time of upload. For me this is a lot better than first having to upload the document and then adding the meta data afterwards.
Writing the base code proved very easy and it didn't take long before I was able to get the documents from the Domino database and send them to the SharePoint site. Getting the meta data proved to be a bit trickier however (though not VERY tricky). The krux was how the meta_info parameter is formatted. The format is pretty much like this: [sourcecode language="c"] string meta_info = "vti_title;SW|" + title; // title is a parameter in my case. [/sourcecode]
Let's go through what this actually means:
"vti_title" is the name of the column that we're adding meta data to. ";" is just a delimiter. "SW" means that the data type is a string, and that it's writable. "|" is the delimiter that's followed by the meta data value.
So, the code above means that the meta_info parameter now contains a writable string value of "title" for the "vti_title" SharePoint column. Easy, huh? Ye, for single value fields this is rather straight forward. However, things do get a bit dodgy when you're trying to send multiple values (for example to a multiple choice field).
I scoured the web for an answer (ok ok, I googled it and didn't find anything except for other people having the same problem) and the MSDN documentation didn't really help (scroll down to the table containing the "Common Field Types"). Sure, I tried using the format specified there but kept on receiving errors in my code that I figured were caused by the meta data. So how did I go by solving this? Luckily, it was very easy.
[sourcecode language="c"] metaInfo += ";Tags;SW|"; tagsList.ForEach(delegate(string tag) // tagsList is a list of strings (tags) e.g. 'tag1','tag2' etc. { metaInfo += @"\;#" + tag; }); metaInfo += @"\;#"; [/sourcecode]
See how easy that was? I mean, it's ALMOST the same as in the previously mentioned documentation, but omitting the '[]' structure.
The final meta_info parameter would then look like this: [sourcecode language="c"] metaInfo = "vti_title;SW|" + title; // title: test if (tagsList.Count > 0) { metaInfo += ";Tags;SW|"; tagsList.ForEach(delegate(string tag) { metaInfo += @"\;#" + tag; }); metaInfo += @"\;#"; } // metaInfo: "vti_title;SW|test;Tags;SW|\;#tag1\;#tag2\;#" [/sourcecode]
And that solved everything.
Original Article














