Adding a Default Action to a Business Data Catalog Entity
Posted
Tuesday, January 29, 2008 3:09 PM
by
CoreyRoth
I tend to write the most about things that I am currently working with. Today I have been working with the Business Data Catalog (BDC) again and I thought I might point out how to configure a default action because it isn't very well documented. A default action is the URL, that will be used when a user clicks for details on the item (either in a BDC webpart or Enterprise Search results). I personally discovered it because I saw an attribute in an example somewhere that had nothing to do with this topic. First, I'll go back and explain how to create an action to begin with. Most BDC tools will do this for you now, but what does it actually emit in the XML? Also of note, a lot of tools will let you create the action but not set it as a default. Here is what typical XML looks like. It goes in the Entity element.
<Actions>
<Action Position="1" IsOpenedInNewWindow="false" Url="{0}" ImageUrl="" Name="Default">
<ActionParameters>
<ActionParameter Name="SiteUrl" Index="0" />
</ActionParameters>
</Action>
</Actions>
The URL allows you to inject the value of a column similar to that of String.Format() using {0} etc. This can be useful if you need to specify a different protocol besides http (i.e.: file://) or if you needed to construct the URL using multiple columns. To set up a default action, you need to take a note of what you named the action (in this case I called it Default). This is how you tell it which action to use as a default.
Now that we have recapped how to create an Action, we need to specify that its a default action. This is actually pretty easy. Create a new Property element in the Properties element of the Entity. Give it an attribute of DefaultAction and specify the name of the Action we defined earlier. Here is how it looks.
<Property Name="DefaultAction" Type="System.String">Default</Property>
When you import the application definition, you will receive a warning like the following.
Could not create profile page for Entity MyEntity. The error is: Default action exists for application 'MyInstance', entity 'MyEntity'. Profile page creation skipped.
This really isn't an error. It is just telling you that since you specified a default action, it did not automatically generate a profile page for the entity. That's all there is to it. Hopefully, more tools will start supporting it out of the box soon.