cancel
Showing results for 
Search instead for 
Did you mean: 

Tips on how to emulate draft functionality in a list

dan_stoll
Nintex Newbie
11 8 3,885

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

8 Comments
jwiskema
Nintex Newbie

This is great, thank you so much!

rszabo
Nintex Newbie

In the workflow there are some cases when this Yes/No solution is not enough.

When you publish a new workflow version or your workflow stops with error right after an item modification, the condtitional workflow start triggers again. And a new unnecessary workflow will start.

To avoid that, you have to change the conditional start value. E.g.: IsDraft in number type,  0 = Draft, 1 = Can Start, 2 = Already Started. The conditional start will eb triggered if the IsDraft=1, and the first step of the workflow is to change that to 2.

skratsch
Nintex Newbie

One issue I've come across with this solution is that logic needs to be added to every form validation rule so that the form can be saved without all of the required fields entered. While this isn't a big deal for smaller forms, for larger forms with extremely complex field validation rules this is a big issue.

Do you know if there is a way to suspend the validation rule checking when Save as Draft is clicked and only have the validation run when Submit is clicked, other than adding this logic into each validation rule?

rszabo
Nintex Newbie

I need this too if there's any.

Stonehage
Nintex Newbie

How about simply adding an 'ItemStatus' field to the form and include it in the validation rules.

For example, options for ItemStatus are Draft and Final.

The validation rules only apply when the form is Set to 'Final' and Other requirements.

skratsch
Nintex Newbie

That is what we have currently implemented, but depending on the size of the form this can add a considerable amount of extra development effort. Also, given the complexity of some of our validation rules adding one more check into the rule adds unnecessary complexity.

As the Saving without closing a form feature was released this month, this issue is no longer relevant. 

Here's the link to the User Voice item where the release was just announced.

Saving without closing a form – Customer Feedback for Nintex 

fccrous
Nintex Newbie

Great post.  Thanks Dan

AasimNaseem
Nintex Newbie

What about the validation rules on the form? Our form will not submit (for the Draft as well) if some rules are failing. I think we have to move those rules to script level, and only run them when we are actually submitting the form.