Thursday, April 8, 2010

Predefaulting Joined Fields on Created By

My client had a requirement to expose the Created By user in the list applet but instead of just showing the row id of the user record, or even the user login, they wanted a more intuitive expression, which I suggested to be [First Name] + ' ' + [Last Name] + ' (' + [Login] + ')'. This works great for them. The only problem is that the field would not predefault correctly when the record was first created. It would only look right after a refresh or requery of the BC. I did a search of metalink and came up with SR 38-1137205351 which basically said what I wanted could not be done because the join to S_CONTACT to get the first and last name would not be done until a requery and there is no system function (like LoginId() or PositionName() ) for the creators full name.

But then I realized I could use a Profile Attribute from the 'Personalization Profile' BC. This BC if you are not familiar with it contains a collection of attributes about the logged in user and all the entities linked to that user (position, organization, contact, division, etc). You can even customize this BC to add your own custom attributes that can be referenced from anywhere. That was not necessary for what I needed though. The attributes in this BC can be referenced using a simple GetProfileAttr statement which can be used in an expression for calculated fields and pre/post default expressions. So here is what I ended up with:



A predefault expression of -> Expr: 'GetProfileAttr(First Name)'. The Created By Display field is what is exposed in the GUI. In addition a pick map will be necessary on this field in the BC:








2 comments:

  1. nice tip.

    Also in your blog ..requesting you to let user post comment anonymously...

    ReplyDelete