Block SharePoint workflow from running unless prerequisites are met - sharepoint

I've got a scenario where I want a workflow to not run if a certain condition is true, otherwise to run when a list item is created. The scenario is for a people management system. If a new list item (staff member) is added to the list then the workflows job is to go between the various departments and get everthing setup. Eg payroll, IT account ect. One of the fields is Start Date that may or may not be entered. If it is entered then I don't want the workflow to run when the item is created. I want the policy on the list to start the workflow on that date. I can add some code into the workflow to end itself if the date is in the future but then this will show as completed on the list. This is a problem because the workflow shouldn't show that it's run as in effect it's waiting for the date to be correct.
In other words, is there something in onWorkflowActivated that allows me to stop the workflow from triggering so that nothing shows up in the site, in essence to suppress the workflow from running as if it was never triggered by the OnCreated event.

Can you add a new step at the beginning of the workflow to fill in the Start Date? I think this makes sense in terms of your workflow because the HR person has an action item on their plate: enter the start date.
Otherwise you could make Start Date a required field on the sharepoint list.

This is SharePoint Designer version, see if you can use the same activities in VS
Create a second workflow that executes the rules after StartDate is set
In the main workflow, create a step with the action 'Wait for Field Change in Current Item' and config it to 'StartDate not Empty'.
The next action will be a 'Start Workflow', executing the second Workflow you created.
You also have a Stop Workflow activity

Related

How to terminate paused workflow from another workflow?

we have a requirement to delete items from a SP list if they were not modified for 15 minutes.
I configured a simple workflow in SP Designer and assigned it to a change action that pauses for 15 minutes and then deletes the item.
Now, if the item changed while the original workflow is paused, a new workflow will be started (I presume) with a new counter.
But how to terminate the original workflow so that it wouldn't delete the item earlier?
We are on SP2013 on Office365.
Thanks,
I think you can solve it other way.
Use SP 2013 workflow platform, and set the trigger to item creation.
create a date/time variable and set to current date or modified field value
pause wf for 15 minutes
if currentItem:Modified less then or equal your variable stored time
if yes: delete item
in transition to stage section use the 3. step again and if yes: select end the workflow, if no: go to stage one
Only way I can think of is to make the workflow run a Powershell script that has the rights to stop workflows. But keeping track of the workflow instance id and the item is going to be a hazzle.
How about simply putting a check at the end of the workflow that checks if the last modified field is older than 15 minutes. If it is older then delete the item, if it is not then terminate that workflow without action.

Running SharePoint 2013 Manual Workflow triggers List Update workflow

I have a SharePoint 2013 list, within it I have a workflow that starts when a list item is updated. This workflow emails people regarding a data change to the list.
I also have a second workflow on that list that can only be run manually which will do some reporting on demand for an item on the list (user checks an item, goes to Workflows, and runs it).
The problem is: When the second manual reporting workflow runs, it also causes the list item update workflow to trigger, which in turn spams my users when no real data change occurred (other than the workflow status field), or at least, it's not a data change that I care about.
Question: How do I prevent the "update workflow" from starting when I'm running the manually-started reporting workflow?

Add fields to Sharepoint Workflow Task

I'm currently making a pretty simple approval workflow in sharepoint using sharepoint designer. One of the design goals that we have for this workflow is that we want to minimize the amount of custom coding that we have to do so I'd appreciate answers that involve using sharepoint designer instead of whipping out VS.
So the workflow should start when a person adds an item to a list.
When the workflow kicks off it would create a task and and assign a due date of +2 business days and assign the responsibility to a group of users
When a user completes the task then it would record the individual person who completed the task as well as the date it was completed.
It's pretty easy to add fields to the list but the purist in me kind of balks at this since these fields would be null and it violates first normal form. Ie a list that went to Task1 but not Task2 would have four fields Task1ApprovedBy, Task1FinishedDate, Task2ApprovedBy, Task2FinishedDate and both the Task2 fields would be null.
--edit--
Sorry If I'm not being clear about the question. I'm using Sharepoint Designer and I would like to update a list item in a lookup when a user completes a task item. How do I select the last task for a particular item that was completed and update that last task two values "Completed By" and Completed Date values? I'd prefer to do this on the Task list since that would also make reporting easier. I'd just create a view on the Task list instead of doing some type of join between the two list to when a particular task was completed.
Thank you for the help!
Jason
It sounds like you need two workflows here. One on the "Main" list and one on the "Tasks" list:
The first workflow is tied to the "Main" list. It fires when a user creates a new list item in the "Main" list. This workflow simply creates a new item in the "Tasks" list (with the correct people assigned, description, dates, etc...)
The second workflow is tied to the "Tasks" list. It fires whenever an item in the Tasks list is changed. The workflow checks to see if the status field is "Complete". If it is, then assign the "Completed By" field to the current person editing the task and assign the "Completed Date" value to today.
(Note that, in a SharePoint Designer workflow, there is no way to evaluate the properties of the list item prior to the update. If a completed task is updated, the SPD workflow will be unable to determine that the task was already completed. Basically, each update to a completed task will update the Completed By/Date fields. If you want a more complex workflow - which only updates when the status is changed to "Complete" - you will need to use Visual Studio).

sharepoint 2007 workflow trigger

I have an initial workflow in Sharepoint Designer that triggers whenever an item is created and also whenever an item has changed in the 'Employee' list .
Within second workflow I am updating the 'Employee' list and the workflow above is triggered.
Is there any way I can check in the intial workflow if the item has been updated by a user or if it was updated by a workflow. In the case if the item was updated by a workflow I would not want to trgigger it.
Many Thanks,
Through SharePoint Designer, you cannot cause an update to an item to not trigger workflows that are listening for it. But, you can cause the workflow to basically be skipped with one extra Step.
Try checking out this article at Microsoft Office, which discusses secondary workflow interactions in SharePoint Designer. In the first step, it identifies whether an item was created by a specific workflow, and cancels the workflow if it isn't. We just need to adapt this - if we successfully identify the item as being modified by your secondary workflow, then we want to cut off the first workflow.
You need to create a new Step in your initial workflow, and move it to the top. In it, choose the Compare Tasks Condition. In that condition, set field to be "Workflow Name", leave the operation as "equals", and set value to be the name of your secondary workflow. Then, add a Stop Workflow Action, specifying some appropriate workflow history message to indicate that the workflow was triggered by the secondary workflow so it was terminated.

Modifying fields for a Workflow Task in Sharepoint

Does anyone know how you can modify the fields in an out-of-the-box (OOTB) Workflow Task (specifically Priority and Due Date)? The OOTB Approval workflow doesn't allow you to set these fields (it allows setting a due date, but not a due time).
I had a cunning plan to create a custom workflow in Visual Studio to set these fields automatically. This involved attaching my custom workflow to the tasks list and editing the tasks as they were created by the Approval workflow. However my custom workflow doesn't fire when new tasks are added to task list by the Approval workflow. And it seems you are unable to manually trigger a workflow on an item in the task list that was created by a workflow.
So in order to set the task fields as they are created by the Approval workflow I'd have to somehow hook into the OOTB Approval workflow directly, which I'm not sure is possible.
Obviously another option would be to recreate the Approval workflow from scratch with InfoPath and Visual Studio, but this seems like overkill to just add priority and time fields to the instantiation form.
Any thoughts?
I've just realised you can edit field such as priority and due date (time) from the task list by selecting Actions > Edit in Datasheet. This works for normal task list items and those created by workflow.
I'd still like to know why a custom workflow that is set to trigger on new items in a task list doesn't fire when a workflow adds items to the task list.
Note: To edit the time a task is due you need to modify the OOTB task list so that the Due Date field is a Date and Time rather than Date Only.

Resources