Monday, November 01, 2010

FIM Email Templates – Fun looking through references

Chalk this up to one of those things I didn't expect to work but it did – the email template will chase a reference attribute and allow you to resolve attributes of the referenced object. Allow me to explain: say, for instance, you want to include a hyperlink to a referenced object in an email notification. The target object contains a reference to the object you'd like to link to like so:

[//Target/Assigned]

In this example, "Assigned" is single-valued reference type in the portal and happens to point to a Person object, but it could point to any object type. Using this information we can embed this into the body or table within a FIM email template and hyperlink it like so:

=[//Target/Assigned/ObjectID]&_p=1>[//Target/Assigned]

NOTE: You need FIM Update 1 applied for this to work.

This will resolve the ObjectID (Resource ID) of the person assigned and build our hyperlink while displaying that persons name. We can also use the same capability to drill right down into the manager of this person like so:

[//Target/Assigned/Manager]

So here we're looking at an object with an assigned person object and we've resolved the assigned person's manager; that's two references we've resolved in a single statement. Let's step it up and add another layer plus additional information:

[//Target/Assigned/Manager/Manager] [//Target/Assigned/Manager/Manager/JobTitle]

Aside from adding some additional processing overhead, these are all completely legal XPath queries and the internal grammar resolvers are thankfully employed within the Email Template which I somehow assumed wasn't the case. I've been using these tricks when building Sets for sometime now but just recently tried it within the Email template.  The one issue here is that you cannot use this on multi-valued reference types. I can only guess that the grammar resolver is not wired up to automatically spit out the properly formatted HTML required to link each item in the list properly and it does throw an error if you try. The only item that I'm aware of that outputs a multi-valued HTML table is the AllChangesAuthorizationTable.

[//RequestParameter/AllChangesAuthorizationTable]

This is an internally generated request parameter and already wrapped in HTML. You could create your own by writing a custom WF activity that dynamically generated the HTML and links required for any multi-valued list and just write it back to an attribute (or WorkflowData) on the object just prior to sending the notification.

Our professional replacement version of the Function Evaluator, which we call the Change Attribute Activity, is wired up to automatically iterate through a multi-valued attribute if it's passed in as the destination attribute allowing us to use the same logic you see above to apply a transform to any referenced object. The built-in Function Evaluator will not allow you to do this.

Newer Posts Older Posts Home