Thursday, January 24, 2008

Displaying a field for only the author of a list item.

Here is the problem: I need to display a custom list field for only the author of a discussion post.

Easy you say? Not so much when you have a custom list definition. You need to get hold of author ID and then compare it to the current user id, in the schema.xml

Getting hold of the author's id has to be done via the Lookup Column. Isn't that fun? Now my field is a checkbox allowing the user to close the discussion.

The important bit of code is:
<displaypattern>
<ifequal>
<expr1>
<lookupcolumn name="Author" showfield="ID">
<expr1>
<expr2>
<UserId/>
</expr2>

So a pretty short post but usefull I think.

No comments: