Sue Hernandez's SharePoint Blog

SharePoint and Related Stuff

SPD 2013 Workflows – Wait for Change booleans

The Scenario:

I have an approval process in my InfoPath form.  When the user presses a button called Approve or a button called Reject, it fills in 3 read-only fields:  ApprovalName (with currently logged in user name); ApprovalDate (with today); and Approval (Boolean with blank default – true means approved, false means rejected).

In SharePoint Designer 2010 what I would do is to use an action called “Wait for field change” (not sure if that’s the exact action name).  I would give it the ApprovalName field and say Wait until Field ApprovalName is not empty.

The reason I choose that field is because I do not wait to wait until Approval is true – because true means approved; what if it’s rejected?  I can’t wait for it to be false either for that same reason.  In 2010, it wouldn’t give you the choice for Boolean fields to say “is not empty” so I chose the text field instead, the person’s name, that gets auto-populated when the button is pressed.

The Problem:

I ran across 2 problems.  The first of which is that in SharePoint Designer 2013, with the 2013-compatible workflow, you can no longer choose things like “Contains”, “Is NOT Equal to”, “Is greater than”, “Is not Empty”, etc.  You can ONLY choose Is Equal To.  As a matter of fact, it’s not even a choice – it’s hard-coded right in there – you can’t even click “is Equal To”.

So what I figured I’d do, is to create another field in InfoPath called ApprovalCompleted as a Boolean, with false as the default.  When you press EITHER the Approve or Reject buttons, it turns the ApprovalCompleted field to true.

So I went in to SharePoint Designer and changed my Wait for Field Change to ApprovalCompleted.  For the value it wouldn’t allow me to fill anything in – it only gave me a Yes or No.  So I chose Yes.

No matter how many times I chose “True” in that blasted InfoPath Form, the Workflow would never get past that Wait for Field Change action – it never equaled.

The Solution:

I Googled around a bit and found that others had the same problem – Boolean fields just never match in a Wait for Field Change action.  I think it’s because it’s storing it as a 1 or 0 and the action expects “Yes” or “No”.

So there’s 2 ways of handling this.  One way is to go back into your InfoPath form and change ApprovalCompleted into a text field and have a textual representation of completion when they click the Approval or Rejection buttons.  That way you can set the Wait for Field Change action to equal a particular string that you’ve set in the InfoPath form.

The other way to do it is to set up a Calculated Field on the Form Library.  So to be clear, you need to promote ApprovalCompleted as a Boolean field (in this particular way of handling it) to the Form Library.  Then you go into the Form Library and create a new field, and call it something like ApprovalCompletedCalc.  Set its formula as just outputting the ApprovalCompleted field, and set its output format as a Number (doesn’t really matter if you use number or string here).  Now in your workflow, you need to Wait for Field Change to be the field ApprovalCompletedCalc and it needs to equal the value 1 – 1 for true, and 0 for false.  No quotes, just the number 1.

Extras:

Couple of interesting things to note.  First is, is that if you have that Calculated Field in your view, and you’ve TOLD it that it’s supposed to be a number, it’s still going to read as “Yes” and “No” EVEN THOUGH it’s really storing 0 and 1.  To be clear, do NOT set your SPD workflow to look for “Yes” or “No” – it needs to be 1 or 0.  But yes, the view is confusing and shows you the text.

Also, in SPD, in a condition, the Yes/No value seems to WORK right.  So if you say “If Approval Is Equal To Yes” it works right.  It captures the “true” or the 1.   So it’s just that other action, the wait for field change action, that is messed up.

 

Advertisements

6 responses to “SPD 2013 Workflows – Wait for Change booleans

  1. Christie B October 21, 2013 at 7:14 pm

    Thank you – I just ran into this problem today! I realized that SPD was insisting on a choice between Yes and No for the Boolean, but since it was working for the conditional part I didn’t know what could be wrong. I changed to text Yes and No and now it works great.

  2. Adrian November 29, 2013 at 7:09 pm

    I was looking for an answer to this vexing problem all afternoon. No replies, no precision… thank God for people like you!

  3. Pam February 4, 2014 at 11:34 pm

    I think you just save my life (I mean job).

  4. jkc September 19, 2014 at 6:13 pm

    SharePoint Booleans are worthless for exactly this reason. Instead we got in the habit of using Choice fields with values Yes and No rather than Booleans. might be inefficient but it’s a lot simpler than trying to keep your Yeses and Noes and 1s and 0s straight.

  5. Chrome Qas January 19, 2015 at 4:52 pm

    Thank you so much, I have been banging my head against a wall for weeks trying to figure out why the YES/NO calculation was working but the workflow wasn’t! Changing the calculation to a number and changing the workflow worked 🙂 God bless you

  6. phantomfrk August 20, 2015 at 8:52 pm

    I still can’t get this to work! Let me explain my situation I have a form that my employees will fill out when they want to request a day off. I have it send an e-mail to the submitter and the person they listed as coverage. The e-mail to the coverage person asks them to Approve or Deny the request. This is done via a Drop Down list that has (blank), Approve, Deny and is stored in CovConf. Then I have a calculated number column called CovCal = IF(ISBLANK(CovConf),1,0)). Then in Sharepoint Designer 2013 I have a step called Coverage Confirmation. It sends the above e-mail mentioned and then waits for CovCal = 1.

    It never makes it past the Coverage Confirmation step!!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: