(For more resources on Oracle, see here.)
The top three things
As we've just seen, the most common things you can do are these:
- Get content approved: This is the most obvious use of the workflow we've just seen.
- Get people notified: Remember when we were adding workflow steps there was a number of required approvers on the Exit Conditions tab in the Add New Step dialog. If we set that to zero we accomplish one important thing: Approvers will get notified, but no action is required of them. It's a great way to "subscribe" a select group of people to an event of your choice.
- Perform custom actions: And if that's not enough you can easily add custom scripts to any step of a workflow. You can change metadata, release items, and send them to other workflows. You can even invoke your custom Java code.
And here's another really powerful thing you can do with custom workflow actions. You can integrate with other systems and move from the local workflow to process orchestration. You can use a Content Server workflow to trigger external processes.
UCM 10gR3 has an Oracle BPEL integration built in. This means that a UCM workflow can be initiated by (or can itself initiate) a BPEL workflow that spans many systems, not just the UCM. This makes ERP systems such as Siebel, PeopleSoft, SAP, and Oracle e-Business Suite easily accessible to the UCM, and content inside the UCM can be easily made available to these systems.
So let's look at the jumps and scripting.
Jumps and scripting
Here's how to add scripting to a workflow:
- In Workflow Admin select a step of a workflow we've just created. Click on the Edit button on the right.
- The Edit Step dialog comes up. Go to the Events tab (as shown in the following screenshot):
There are three events that you can add custom handlers for:
- Entry: This event triggers when an item arrives at the step.
- Update: This happens when an item or its metadata is updated. It's also initiated every hour by a timer event, Workflow Update Cycle. Use it for sending reminders to approvers or escalating the item to an alternative person after your approval period has expired.
- Exit: This event is triggered when an item has been approved and is about to exit the step. If you have defined Additional Exit Conditions on the Exit Conditions tab then those will be satisfied before this event fires.
The following diagram illustrates the sequence of states and corresponding events that are fired when a content item arrives at a workflow step:
Great! But how do we can actually add the jumps and custom scripts to a workflow step?
How to add a jump to a workflow step
Let's add an exception where content submitted by sysadmin will bypass our Manager Approval workflow. We will use a jump—a construct that causes an item to skip the normal workflow sequence and follow an alternative path. Here's how to do it:
- Add a jump to an Entry event of our very first step. On the Events tab of the Edit Step dialog, click on the Edit button—the one next to the Entry event.
- The Edit Script dialog displays (as shown in the following screenshot):
- Click on the Add button. The Add Jump dialog comes up (as shown in the following screenshot):
- Let's call the jump Sysadmin WF bypass. You don't need to change anything else at this point. Click on OK to get back to the Edit Script dialog.
- In the Field drop-down box pick Author.
- Click on the Select… button next to the Value box. Pick sysadmin (if you have trouble locating sysadmin in the list of users, make sure that the filter check-box is un-checked).
- Click the Add button below the Value field. Make sure that your clause appears in the Script Clauses box below.
- In the Target Step dropdown pick Next Step. Once you have done so the value will change to its script equivalent, @wfCurrentStep(1).
- If you have more than one step in the workflow, change 1 to the number of steps you have. This will make sure that you jump past the last step and exit the workflow. Here's how the completed dialog will look (as shown in the following screenshot):
- Click on OK to close. You're now back to the Events tab on the Edit Step dialog. Notice a few lines of script being added to the box next to the Entry event (as shown in the following screenshot):
- OK the dialog. It's time to test your changes.
- Check in a new document. Make sure you set the Author field to sysadmin. Set your Security Group to accounting, and Account to accounting/payable/current. If you don't, the item will not enter our workflow in the first place (as shown in the following screenshot):
- Complete your check-in and follow the link to go to the Content Info page. See the status of the item. It should be set to Released. That's right. The item got right out of the workflow.
Check in a new document again, but use some other author. Notice how your item will enter the workflow and stay there. As you've seen, the dialog we used for creating a jump is simply a code generator. It created a few lines of script we needed to add the handler for the Entry event.
Click on the Edit button next to that code and pick Edit Current to study it. You can find all the script function definitions in iDoc Reference Guide.
Perfect! And we're still not done.
What if you have a few common steps that you'd like to reuse in a bunch of workflows? Would you just have to manually recreate them? Nope. There are several solutions that allow you to reuse parts of the workflow. The one I find to be most useful is sub workflows.
(For more resources on Oracle, see here.)
Sub workflows are reusable blocks of steps that you can then jump into from a number of other workflows. It's easy to create a sub workflow, just keep the Has Criteria Definition box un-checked when you create a regular criteria workflow (as shown in the following screenshot):
This is it…
And if this is not enough, let's look at the workflows that can hold multiple items at once. Let's look at the Manual or Basic workflows.
The reason they're called "Basic" or "Manual" is because this type of a workflow doesn't trigger automatically. It has to be started by hand, by an administrator, or a power user.
The User's role must have a right to run the Workflow Admin application. Go to Security Permissions By Role | Edit Applet Rights| in the User Admin applet to make sure.
Basic Workflows have a big advantage, they can hold more than one content item and get them approved together. You can even create new item placeholders and get them elaborated as part of the workflow.
How do you create a Basic Workflow? Let me show you in the following section.
Lab 8: Using manual workflows
Follow these steps:
- Bring up Workflow Admin and go to the Workflows tab (as shown in the following screenshot):
- Click on the Add… button and create new workflow.
- Select content items that you're going to run through the approval process.
- Select one or more contributors. The first step of a basic workflow is always a contribution step. Contributors will be invited to check-out and check back in the items in the workflow.
- Create one or more approval steps just as we did in Lab 7.
- Your basic workflow is now ready to start (as shown in the following screenshot):
- Start it by clicking on the Start button at the bottom right.
- Log in as one of the contributors and go to My Workflow Assignments. Use the Actions column on your right to complete your workflow assignment.
Congratulations! You've just created and tested a basic workflow.
But what if you have to send additional items through a very similar basic workflow? Do you have to keep on recreating workflow steps every time? Of course not! Use Templates. Here's how to create templates.
Basic workflow templates
In Workflow Admin switch to the Templates tab. Give the new template a name and description. Now you can add and configure workflow steps just as you would in a "normal" basic workflow (as shown in the following screenshot):
Once you have the template defined, you can use it for creating new basic workflows. Just check the Use Template checkbox on the Add New Workflow dialog.
Can you put yourself in the picture? See how much time the templates would save you?
And here's an even bigger time saver. Let me show you how to group approvers.
How to group approvers
I bet you've asked this question a few times while reading this article. How would you add a group of users as contributors or approvers? You've also seen Add Alias and Add Token buttons. So here's how to use aliases to group approvers.
Using aliases to group approvers
It's easy to create aliases with the User Admin applet. This is it! Now you can use Add Alias button on workflow steps and workflow template dialogs to add a group of users.
Everyone in the group will receive notifications. And if just one approver is required to complete a workflow step any user in that alias can do it.
If you think that was useful then check out the next section. I'll show you how to select workflow approvers dynamically, using script. So here's how to use tokens to pick approvers dynamically.
Using tokens to pick approvers dynamically
What if you host a number of websites for your clients, and you need your website owners to approve their content? I know you can create one workflow per site. But is there a way to just use one workflow? What if you allow your users to dynamically create their own sites and one workflow per site is just not the choice you want to make?
Here's how you can do it:
- We're going to create groups of approvers for each site using aliases. This is pretty obvious but the next step holds the real key:
- We're going to define a token that will let our workflow select the right alias for each content item.
Let's define our aliases first.
Here's a little trick we're going to use. Let's assume that we have a meta field called xWebsites that holds the name of the website, that a content item belongs to.
If you don't have the Site Studio component installed in your Content Server, you will most likely not have a field called xWebsites defined yet. Just go ahead and create it yourself, so you can follow the steps next.
We're going to use the actual values of this field as the names of the aliases.
- Bring up the User Admin applet. Go to the Aliases tab and click on the New button below.
- Let's create an alias (group of users) called marketing_intranet (as shown in the following screenshot):
- Go ahead and create aliases to other websites such as marketing_extranet and corporate_www.
Perfect. We're done creating aliases. Now it's the time to leverage the power of tokens:
- Bring up Workflow Admin. Select Options Tokens| from the menu.
- The Workflow Tokens dialog comes up. Click on the Add button at the bottom.
- The Add Token dialog opens. Let's call it Web_Sites (as shown in the following screenshot):
- Click on the Add button. The Add Token User dialog comes up (as shown in the following screenshot).
- Pick Alias for the Type and xWebsites for the Name.
- OK the dialogs to save changes.
We're all done! You can now add your newly created token to workflows. How does it work?
Actually it is simple. If we check in a content item with xWebsites set to marketing_intranet, the token will get evaluated to marketing_intranet. Now the token was created for an alias so it will resolve to an alias of marketing_intranet. This is it.
Now we have a dynamic way to pick a group of approvers based on the metadata values. Nice!
We've learned almost all there is to know about the Content Server workflows.
You've seen the different types of workflows and you've created one of each. You've seen how to use scripting to customize them, how to create reusable pieces, and how to group approvers.