John Underwood is a Technical Evangelist at ThreeWill. He has nearly thirty years of software development experience. He is an experienced technical instructor with superior presentation skills and is proficient in delivering standard curriculum as well as developing and delivering custom curriculum.
John Underwood here at ThreeWill and today I’m going to show you some tips and tricks that I’ve learned in some recent work with workflows. So you’ll notice on the screen that I have a sample library named resumes and then it has a choice field in it that would let us track the status of a resume if someone goes through the hiring process. Now I have a desire to make it so that I can have a workflow that runs and does certain things as the person advances through the process. So what I’m going to do now is go to design and create a new workflow and then we’ll see if we can make the logic work on this.
Now I begin the process by kind of laying out my stages. This is something that I’ve started to do recently where I almost think of stages as being like a block diagram um, those of you that have done UML or other entity modeling things, think of this as being the high level entities or steps that you’re going to take and then once I’ve kind of laid out the basic flow of the problem then we’ll go in and fill the details. So you can see as I complete these that the names of the stages kind of represent the different parts of the process and I think it’s really important that you name these stages in user friendly fashion.
After all, if you’re not already aware of this you’re going to see that the stage names actually show up in a place where user would easily be able to see them, not only that, there’s really how they’re going to make a determination about where you are in the workflow process. So you can see I’ve got all of my stages laid out now, so I’m going to go in and add a little logic and basically what I want to do here is wait until my status changes. Now you can see I’ve put in a wait here and so I’m going to tell it what field I’m waiting on and then once I’ve chosen my candidate status field notice a little challenge here, I can’t click on the equals part of this and say that I want it to equal or not equal or be greater than or less than or any of the kinds of comparisons that we would expect.
So I could swear that earlier versions, 2010, had this, maybe they did, maybe they didn’t but either way that’s not going to work in this circumstance, so what I’m going to do is delete the step and I’m going to try another approach. So my next approach would be to in a parallel block and essentially what I would say is I’m gonna wait for all of the various values that might come up, so you can see I’m laying that out on the screen right now or I’m going to say, wait for this value, wait for that value, wait for the other value and then the idea here is that once one of these hits I can then progress ahead and I can do what I need to do.
Now at a very high level I see two potential problems with this. The first one is in my case I’m only waiting on three things. If you had a choice field that had eight or nine different items this might become a bit laborious and you might have to seek another approach to solve the problem. But the bigger or more immediate problem that I have here is the nature of doing things in parallel, so if you didn’t already know this what you’re about to find out is that when you do these parallel actions you’re not going to continue until all of them complete and the challenge that I face here is that by definition these are sort of mutually exclusive, so in effect what I’ve done is put in some logic that essentially freezes me where I’m at.
Now the good news here is that we do have a solution to our problem, so what I want to do is delete parallel block and then I’m going to add another parallel block, and in this case instead of placing actions directly inside the parallel block, instead I’m going to place steps and then place my actions inside of that and as we go along you’ll see why this is important. So you can see I’ve entered the three steps and I’m going to name each of them appropriately based on what the step is going to be responsible for.
Now you’ll notice just above my parallel block I’m going to declare a new workflow variable, I’m going to name it done waiting, and it’s going to be of type Boolean and what purpose is it going to serve, you’ll see this unfold over the next few moments but basically I’m going to use this Boolean as a way to exit my parallel block once one of my wait conditions is met. So as you can see I’ve declared it is Boolean and I’m going to set its initial value to false or no.
Now I’ll go down into each of my steps and not only will I put in the wait condition that I’m interested in but I’ll also but in some logic that would change my done waiting variable from no to yes, by doing this in effect what I’m saying is I want to short circuit the parallel block and go ahead and exit.
Now you can see I’ve completed filling in all of the various steps that are involved in my parallel block. The last little bit here is I’ve got to tell this parallel block that it’s okay to exit once this Boolean becomes true. So I’m going to right click and go to advance properties and essentially I’m going to tell it the variable to monitor, once that variable becomes true then it will exit the wait condition and continue on to the rest of the workflow.
Now if you look carefully at the screen you’ll see that I’ve added some additional parts here such as the logic to edit this stage, I’ve also put some messages in the other stages, so I’ll check for any syntax errors and then I’ll go ahead and publish this so that we can test the logic.
Now I’ll switch to my browser and you can see I already have the resume’s list loaded. I’ll go ahead and select one of the resumes and then invoke the workflow that I’ve just configured. You can see the resume candidate flow, I’m going to invoke that and then once I’ve invoked it I’ll go back and refresh the list just so that we can see that it has started. Once we’ve started it we can go in and edit a property value and in effect move this candidate to another state. In this case we’re going to say that this was a candidate we were not interested in hiring so their status is now set to rejected.
Note that once I’ve set it to rejected I can now go look at the workflow history and actually see the steps that we went through and indeed my wait logic did do the right thing, it waited until we achieved a certain state and then transitioned to the proper stage of the workflow so that we could complete the process.
So to recap what we covered here, number one, when you’re dealing with a choice field and you need to wait for various values there’s no way that you can change from equal to not equal on a normal wait, instead we have to use a parallel block. Second, when we use the parallel block we want to put steps in the parallel block and actions inside of steps as opposed to putting the steps directly in the parallel block and finally remember that we’ll use a Boolean variable along with an advance property of the parallel block to short circuit and exit once a single condition is met.