<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dom Cosgrove Blog &#187; BDC</title>
	<atom:link href="http://blog.domcosgrove.com/tag/bdc/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.domcosgrove.com</link>
	<description>Dom&#039;s views on the SharePoint World</description>
	<lastBuildDate>Tue, 18 Oct 2011 12:59:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Setting the value of a BDC field Programmatically</title>
		<link>http://blog.domcosgrove.com/setting-the-value-of-a-bdc-field-programmatically/</link>
		<comments>http://blog.domcosgrove.com/setting-the-value-of-a-bdc-field-programmatically/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 08:24:33 +0000</pubDate>
		<dc:creator>Dominick Cosgrove</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[BDC]]></category>

		<guid isPermaLink="false">http://blog.domcosgrove.com/?p=30</guid>
		<description><![CDATA[You cannot set the value of a BDC (Business Data Catalog) field in the same way that you set standard fields in SharePoint e.g: SPListItem item = myList.Items.Add(); item["Title"] = "Product Information"; Instead you must use the EncodeEntityInstanceId method of the EntityInstanceIdEncoder class of the  Microsoft.Office.Server.ApplicationRegistry.Infrastructure class library. First you can detect if your field [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>You cannot set the value of a BDC (Business Data Catalog) field in the same way that you set standard fields in SharePoint e.g:</p>
<div style="line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.5%; font-family: consolas, 'Courier New', courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text; border: gray 1px solid; padding: 4px;">
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">SPListItem item = myList.Items.Add();
item[<span style="color: #006080;">"Title"</span>] = <span style="color: #006080;">"Product Information"</span>;</pre>
</div>
<p>Instead you must use the EncodeEntityInstanceId method of the EntityInstanceIdEncoder class of the  Microsoft.Office.Server.ApplicationRegistry.Infrastructure class library. First you can detect if your field is a BDC field by:</p>
<div style="line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.5%; font-family: consolas, 'Courier New', courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text; border: gray 1px solid; padding: 4px;">
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #0000ff;">if</span>(item.Fields[<span style="color: #006080;">"MyField"</span>].TypeAsString == <span style="color: #006080;">"BusinessData"</span>)</pre>
</div>
<p>You then need to:</p>
<div style="line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.5%; font-family: consolas, 'Courier New', courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text; border: gray 1px solid; padding: 4px;">
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #008000;">//Get a reference to the field</span>
SPField myField = spItem.Fields[<span style="color: #006080;">"EmployeeID];

//Get the entity Name for the field
XmlDocument xmlData = new XmlDocument();
xmlData.LoadXml(myField.SchemaXml);
String entityName = xmlData.FirstChild.Attributes["</span>RelatedFieldWssStaticName<span style="color: #006080;">"].Value;

//Set the Entity Instance value
spItem[entityName] = EntityInstanceIdEncoder.EncodeEntityInstanceId(new object[] { "</span>123456<span style="color: #006080;">" });

//Set the field display value
spItem["</span>EmployeeID<span style="color: #006080;">"] = "</span>123456;</pre>
</div>
</div>
<div>1 comments <span> </span>Saturday, January 24, 2009 <span><a title="Edit Post" href="http://www.blogger.com/post-edit.g?blogID=2398837868960473579&amp;postID=5266961404946009785"></a></span></div>
<div><a name="4939642700629188219"></a></p>
<h2><a href="http://spdom.blogspot.com/2009/01/connected-webparts-no-filtered.html">Connected WebParts – No Filtered Parameters</a></h2>
<p><span>Posted by <span>Dominick Cosgrove</span> </span>at <abbr title="2009-01-21T21:05:00Z">9:05 PM</abbr> Labels: <a rel="tag" href="http://spdom.blogspot.com/search/label/Development">Development</a>, <a rel="tag" href="http://spdom.blogspot.com/search/label/SharePoint">SharePoint</a></div>
<div>
<p>OK this may be obvious but it caught me out and god knows it caused me to tear my hair out for a while.</p>
<p>I was creating a custom consumer WebPart that I wanted to connect to a URL and BDC Filter WebParts. There are loads of examples out there of how to do this. Basically Windows SharePoint Services makes use of the connection framework and provides additional interfaces called <strong>IFilterValues</strong> and <strong>IItransformableFilterValues</strong> to make it easy to create Web Part connections for filtering scenarios.</p>
<p>The issue I had was once I implement the code as per the various examples on the web, there were no filter parameters available to when you configure the connection.</p>
<p><a href="http://lh4.ggpht.com/_iiSGaNIff2A/SXeN-TPPNHI/AAAAAAAAACc/JaOyvdISTeg/s1600-h/image4.png"><img style="display: inline; border-width: 0px;" title="image" src="http://lh6.ggpht.com/_iiSGaNIff2A/SXeN-51vgFI/AAAAAAAAACg/utTnleDtkLw/image_thumb2.png?imgmax=800" border="0" alt="image" width="318" height="163" /></a></p>
<p>The problem lies with the <strong>ConsumerParameterCapabilities </strong>Enumeration<strong>,</strong> which is used by a consumer Web part to indicate supported filter parameter capabilities. The samples on the web all seem to use:</p>
<p>ConsumerParameterCapabilities.SupportsMultipleValues</p>
<p><em><strong><span style="font-size: medium;">and</span></strong></em></p>
<p>ConsumerParameterCapabilities.SupportsAllValue</p>
<p>Unfortunately this did not seem sufficient for the BDC and URL filter WebParts, after some trail and error I established that the minimum required is:</p>
<p>ConsumerParameterCapabilities.SupportsAllValue</p>
<p><span style="font-size: medium;"><strong><em>or</em></strong></span></p>
<p>ConsumerParameterCapabilities.SupportsEmptyValue</p>
<p>How ever it does work if you specify all ConsumerParameterCapabilites. The ConsumerParameter method allows you to have or statements so you can effectively set the parameters like this:</p>
<div style="line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.5%; font-family: consolas, 'Courier New', courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text; border: gray 1px solid; padding: 4px;">
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">parameters.Add(<span style="color: #0000ff;">new</span> ConsumerParameter(
                    <span style="color: #006080;">"Personnel Number"</span>,
                    ConsumerParameterCapabilities.SupportsAllValue
                    |
                    ConsumerParameterCapabilities.SupportsEmptyValue
                    )</pre>
</div>
<p><strong><em><span style="font-size: medium;">or </span></em></strong></p>
<div style="line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.5%; font-family: consolas, 'Courier New', courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text; border: gray 1px solid; padding: 4px;">
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">parameters.Add(<span style="color: #0000ff;">new</span> ConsumerParameter(
                    <span style="color: #006080;">"Personnel Number"</span>,
                    ConsumerParameterCapabilities.SupportsAllValue
                    |
                    ConsumerParameterCapabilities.SupportsEmptyValue
                    |
                    ConsumerParameterCapabilities.SupportsMultipleValues
                    |
                    ConsumerParameterCapabilities.SupportsSingleValue
                    )
                );</pre>
</div>
<p>So to summaries, make sure you are using the correct ConsumerParameterCapabilities for your provider webpart or else you will not see the parameters you are expecting to see.</p>
<p><strong>References</strong></p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms569191.aspx">Writing a Simple Filter Consumer Web Part Sample</a></p>
<p><a href="http://www.sharepointblogs.com/tonstegeman/archive/2007/09/21/moss-2007-filter-webparts-part-1-create-your-own-provider-and-consumer.aspx">MOSS 2007 Filter webparts part 1 &#8211; create your own provider and consumer</a></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.domcosgrove.com/setting-the-value-of-a-bdc-field-programmatically/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

