dan.stoll

Tips on how to emulate draft functionality in a list

Blog Post created by dan.stoll Employee on Mar 4, 2016

This is a simple trick that I've been using for a while that allows you to have some of the Draft capability without having to turn on Content Approval and versioning. Which let's be honest is a little much in some cases. The trick is to use 2 buttons on a form, one "Save as Draft" the other "Save and Submit". In the list, create a hidden column and call it "Draft".  This column needs to be a "Single line of text" field (It doesn't need to be hidden this is just my preference.)

 

Now lets configure those buttons.

Firstly let's configure the "Save as Draft" button. Under 'Advanced' connect the button to the new field 'Draft'

Once you have connected that, type "yes" into the field 'Value returned'

Repeat this process for the 'Save and Submit'

 

Both these buttons save the information back to the list.. Difference being; when I use the 'Save as Draft' button the 'Draft' column value is set to 'Yes'

 

So this is great you say, now this is where we head to the workflow and place in some rules to hand this..

For Workflow On-Prem you have the ability to put in some conditions on when a workflow should start. You can find these setting in the ribbon under 'Workflow Settings' and then change 'Start when items are created' to 'Conditional'

So for this example, select 'Conditions' and you want workflows to start on create only when the 'Draft' column equals 'No'

Now change the 'Start when items are modified' to 'Conditional'

Here we need to add 2 conditions. Because we only want to start the workflow when the item was a draft previously and now it isn't. The reason I don't use a compare is that for some reason I changed a published item to a draft, I wouldn't want to the workflow to run.

 

Easy right !!

But let's say your in O365 and you aren't able to use start conditions. All we need to do really is build this same logic into the start of the workflow.

Firstly we need to change the workflow start settings to run the workflow when the item is created and also when it is modified

First action we want to place is a 'Run If'

Now because I don't have the ability to look back at the old value, I'm going to create a new hidden column to store that, so I can check it as part of my logic.

I've created a new column called 'Draft Old Value', and I've got a couple of 'Set field value' actions mixed in now as well, to ensure the 'Draft Old Value' is set right. You'll see in the picture above that I have an action there that sets that field to 'Yes' before it terminates the workflow.

Now we need a second 'Run If', to handle the situation when a draft item is now published. This run if, will allow through items that were in draft but are now published. Items that were published and have been edited, will not continue

With the following settings.

 

Notice that after the 'Run If' there is another 'Set Field Value'. This will set the 'Draft Old Value' to No, meaning that once the workflow has run through the first time as a published item. The filed will be set as so when it is edited again, the workflow will cancel out. If the published item is saved as a draft again the first 'Run If' will get it and set the "Draft Old Value' back to Yes and the cycle will start again.

 

So hopefully this helps out when you have the requirements around emulating 'Draft' functionality in a SharePoint list.

 

Until next time

Outcomes