Wednesday, February 27, 2008

Display Custom Field in a Content Query Web Part

Today I struggled with a problem when trying to display a custom field into my CQWP. I tried to display a custom field whose internal field consist of two parts. eg. News Date.

When I filled in the internal field name this way:
<.property name="CommonViewFields" type="string".>News Date,Text;<./property.>" the field didn't render.

<.property name="CommonViewFields" type="string".>News_x0020_Date,Text;<./property.>"

The characters _x0020_ represent the blank space.

Retrieve List Guids, Internal Field Names & ContentTypeIDs

When you are in want of some Guids, Internal Fieldnames or ContenttypeIDs during the development... you don't have to look that far. I just realized that the info is available in the URL.

So when you need a List Guid, just navigate to the list settings page and copy the Guid after the "List=" string. Be aware of that the GUID is URL encoded. For that reason you have to decode the Guid or just remove the special characters and add braces.

For a ContenttypeID, navigate to the contenttype in the site contenttype gallery and copy the ID after the "ctype=" string out of the URL.

For an internal Fieldname, navigate to the site column page for a particular column and copy the fieldname after the "field=" string out of the URL.

Sunday, February 3, 2008

Automatically activate a Site/Web Scoped Feature

I'm wondering if there is a way to automatically activate Site or Web scoped features after the feature installation. I did some research and found a XML attibute "ActivateOnDefault", which you can place in the feature definition file (feature.xml).

I placed the attribute into the feature.xml to force the feature to activate himself after installing, with no results...

The ActivateOnDefault attribute does not apply to site collection (Site) or Web site (Web) scoped Features.

In general, Farm-scoped Features become activated during installation, and when a new Web application is created, all installed Web application-scoped Features in it become activated.

So I think the only way to accomplish this is to write some code within the "FeatureInstalled" method of the FeatureEventHandler: Activate features through code.

Problem with deleting a solution

For once I got an error when trying to remove an existing SharePoint Solution (.wsp) from the SharePoint Server.

The solution cannot be removed when a job is scheduled or running

Also when you go to the Central Administration > Operations > Solution Management, you will notice that an error shows up in the list of solutions.

Off course there is a way to fix this. Alex Thissens wrote a nice blogpost of this issue. Maybe there are other ways to fix this, but Alex' way worked for me.