Tuesday, July 19, 2011

Save time and wow your friends with this cool Dynamic Converter hack

If you ever wanted to add logic to the output of dynamic converter - this article will give you the best "gotcha" in a longest time. In the next few minutes I'll show you how to conditionally display parts of a dynamically converted word document - based on ... the query string parameters!

Yeah, you won't find this in the manual, but  if you think about it - its a really simple and natural thing to do....

Let’s imagine that you have a bunch of word documents that contain a summary and the full story (or English and French sections) and you only want to display the first sections in your  summary page, and full docs on the story page. And you don’t want to have to store your summary in a separate word document. 

Using just one document will avoid duplicated content and make it much easier and intuitive to update - all content in one place.

To show you exactly how to do it I've setup  a simple template with a region and inserted a dynamic converted word document in it. 

What I want to see happening is this:
  • When I don’t send anything on the query string or send "show=0" - I only want to see the summary or my "regular content" section (See screenshot below)




  • When I send "show=1" on the query string - I want to see my entire document (See screenshot below)



So how do I make my converted word document "that dynamic"?

Well, I can embed some java script in the document as hidden text but this is really messy and fragile. Contributors will have to look at this every day and will soon begin to hate you to a degree that actually affects your digestion system. Don’t do that!

So here's a better option. Let me give you a little hint - dynamic converter converts native application content to.... HCSTs!

Yes, you can simply use iDoc in your dynamic converter template!

Here's how:
  • In your word document create a new paragraph style. Formatting and the style name are not important for what we're trying to accomplish here
  • Apply your new style to the section that you want to dynamically show and hide
  • Save your document and check it into the Content Server.
  • Fire up your Dynamic converter Template Editor and click Element Setup on the right
  • Create a Dynamic converter element (on the Elements tab) and a new style (On the Styles tab)
  • Now match them up (Below is a screenshot showing you how you can map a Word Style called "Image Aligned Left" to a new element called imgAlignedLeft)




  • Go back to the Elements tab and select the element you've just created and mapped
  • Click Properties and go to HTML Tag tab
  • See screenshot below for a sample of how you can add iDoc script to hide your section based on the value from the query string!

Oh, but  what if you want to use other styles in your story and cannot apply your new style to an entire section?

Well, how about a pair of styles? Call the first one "Begin Body" and only specify a custom tag before the content. The other one will be the "End Body" and use the <$endif$> as its custom tag after the content




There  you have it

Really simple if you think about it! Using the if statement as a custom before tag for the element! That's it - entire solution fits in just 8 words :)

Hope you enjoyed this neat and powerful hack. And remember, if you ever need a hand with your UCM project, task at hand, training, support or simply an independent third party opinion - we're one email away. Just shoot us a quick note at contact at stellentExperts dot com. You'll be glad you did, just like a lot of  folks in these companies...

Oh, and we don’t have any sales people working here so after you do contact us - no one will be harassing you in the weeks to come - guaranteed!

Cheers
D




Tuesday, July 12, 2011

How to get 30% off The Oracle UCM Handbook....

If you still haven't claimed your copy of The Oracle UCM Handbook - now it may be the best time to do so. For a short time only Packs offers 30% off eBook and 20% off - any print book in their Oracle Series

Check it out at http://www.packtpub.com/article/50th-oracle-book-offer

Monday, July 4, 2011

Content Server design flaw discovered: "Sometimes it takes a Big Boss to approve a workflow"

Last week I've got an email form a senior developer, forwarded by our client in Europe. The guy that shortly after found a major design flaw in Content Server workflow engine! 

They wanted to have a user's manager approve their content, so they simply added a user information field called Manager:



Sounds like a simple and intuitive solution, right?

Yep. And they've created a token

<$wfAddUser(getUserValue("uManager"), "user")$>

and added this "Manager Approval" step to the workflow.

Now what they found is this: The manager did receive email notification and the were able to see the workflow, but they couldn’t approve or reject!

So he was asking me why....

I told him that only the Big Boss can approve the workflow and if he sets the user's manager value to himself - the guy will be able to approve :) He laughed but did try to prove his point...

And he was shocked to see that....

It worked like magic!

So did we discover a design flaw? A piece of code somewhere in Content Server that let’s you approve the workflow if there's no manager higher then you and you're your own boss?

Uh.. Not really.

You see, what Eric didn’t consider is the fact that the token is re-evaluated every time. When the item goes into the workflow, notification is sent to the manager of the guy who submitted the item. All good! But once the manager arrives to approve the item - the token is evaluated again! Guess why the person with the Manager set to themselves can approve the item?

Solution?

Well, if you're set on having the Manager specified in the User Attribute, write this value to a workflow variable or an extended metadata value and add users to the step based on that. This way you know that the value won't change when approver is there to act on the item.... Or simply have a dropdown of approvers on the check in form (let’s say, you name the filed xWfApprover) and use that content metadata field in your token instead:

<$wfAddUser(xWfApprover, "user")$>

Guess what? Everything's working as designed....