Insight

Insight from Agora Consultants

Workflows in SharePoint Designer

Whether you are developing a workflow for Project Server 2013 or Project Online, SharePoint Designer has many useful functions that are not obvious at first glance. This blog will highlight those "hidden" features and how to use them in real situations.

Workflow Restart

In Project Server administrators have the ability to restart a workflow to any stage. In the past versions of Project Server this meant having to code a special path through the workflow skipping past all submits and approvals. Looking at SharePoint Designer, there is no property from which we can read if the project is currently skipping. So I thought “Great, workflow restart is handled by the new workflow engine, I don’t have to worry about it”. That turned out to be false. The good news is, it’s easy to build in this logic, it’s just not obvious.

Every stage should have this If condition as the first element:

If this condition is missing, then even I you try to restart the workflow to a later stage, it will stall at this one. To add this if condition, go to the ribbon and select the option below.

The naming is a bit odd, but now that you have seen this you know what to do. When this if is added to all stages, voila, you can restart your workflow anywhere you want.


Copy and Paste

If you work with SharePoint Desginer for a while you will realize that you cannot copy and paste certain actions. This can get frustrating after a while because you will see this:

And have to rebuild the entire approval/email action from scratch. There is a workaround to this and it involves steps. Before you create any action (aside from the restart If condition above), create a step first and put your task in that.

This way, you can copy and paste these steps to any other stage in the workflow and it will never give you that dreaded popup again. This will save you a ton of time.

Careful Creating Stages

This is not a feature, more of a warning. If you are just starting your workflow, and you set up the first two stages that both transition to “End of Workflow” (as below). Do NOT save the workflow and do NOT close SharePoint Designer.

What happens is, “Sponsor Approval” is a stand-alone stage. No stage is transitioning to it, and it is not transitioning to another stage. If you ever save a workflow like this and try to reopen it, it will never open again. You will have no choice but to rebuild the whole workflow.

Let this be a warning, before saving your workflow go through all the transitions to make sure that each stage is being referenced by at least one other.

String Manipulation

SharePoint Designer has plenty of string manipulation methods:

It can be hard to tell for a developer (certainly was for me), but with these actions you can do all the permutations of substring, indexOf, replace, and trim. I particularly find these actions useful when I am reading multiple values from a custom field (for example, a comma separated list of email addresses).

Direct Link to Project

If you look at the properties for a project, you will see that there is no property that gives a link to the project or its project site. Follow these steps to create a link to a project’s PDP.

Type a sentence such as “click here to navigate to the project”, and then select “here”. Click the hyperlink icon on the right of the window.

The edit hyperlink window appears, click Edit…

The String Builder window appears. Click on Add or Change Lookup. For Data Source, choose Workflow Context, and for field choose Current Site URL.

Once you click OK you can see the current site URL placeholder added to the String Builder. After that, type projectdrilldown.aspx?projuid=.

Finally, click Add or Change Lookup again. This time let the data source be Project and the field be Project UID. When it’s all done the link should look like this.

Click OK to finish.

NOTE: I have noticed a change in the Current Site URL variable in PS online. On some instances, the current site URL ends with a / and on some it doesn’t. When beginning development its best to run the workflow and log the current site URL to see what it contains.

Calling an oData Feed

Microsoft recently released an article on how to call the Project Server oData feed from SharePoint Designer. You can find a full guide here: https://msdn.microsoft.com/library/office/mt143443.aspx.

The End

I hope you have learned a few things and that this blog saves you the countless hours I have spent figuring it out.





 
Comments are closed