SharePoint User Group UK

Share the knowledge!

Welcome to SharePoint User Group UK Sign in | Join | Help
in
Home Blogs Forums Photos Files Roller

Workflow doesn't fire automatically for certain users

Last post 06-09-2008, 9:34 AM by Cimares. 11 replies.
Sort Posts: Previous Next
  •  05-15-2008, 11:46 AM 10731

    Workflow doesn't fire automatically for certain users

    I have a small executable application which runs at 10 mintues past midnight to check the contents of one of my lists.

    If it finds a meeting in the list that is due to occur in 5 days time (no more, no less!) then it will make a small modification to the item:

    Dim oItem As SPItem

    For Each oItem In oListItemCol

    intCounter = intCounter + 1

    oItem("Five day flag") = "Yes"

    oItem("Last Operation") = "Five Day"

    oItem.Update()

    Next

    The list has some workflows associated with it, but for some reason when this automated process is changing the items it's not firing the events.

    The user which is being used to run the job has rights on the site. They are a member of the group of users with contribute access who would normally edit the items during the day which can cause the workflow to run too - which it does.

    I'm utterly stumped by this one. I've had to manually fire the workflow this morning for the 3 items that were succesfully changed at 00:10, but whom didn't trigger the workflow themselves.

    No error logs were created either to suggest anything wrong.

  •  05-15-2008, 4:20 PM 10756 in reply to 10731

    Re: Workflow doesn't fire automatically for certain users

    Stephen,

    How are you updating the item? Are you using item.SystemUpdate() or item.update()? I don't believe System.Update() triggers the ItemUpated event handler.

    If that proves to be the case, then you'd be quite safe to add some code to your timer event that triggers the workflow yourself. (I have some sample code of using the workflow manager to evaluate workflows in a library if thats of use?)

    Paul.


    www.myfatblog.co.uk
    MCTS: WSS 3.0
    MCTS: MOSS 2007
  •  05-15-2008, 4:26 PM 10758 in reply to 10756

    Re: Workflow doesn't fire automatically for certain users

    Oh, now code that can trigger workflows would be supoib! It's something we've talked up in here as a mythical beast of some sort. We hoped it existed, like Nessie, but didn't think it did, ... again like Nessie.

    I am just using Item.update, which is setting the last modified user to be the account I'm using for the timer job. Which made it all the more puzzling.

  •  05-15-2008, 4:57 PM 10765 in reply to 10758

    Re: Workflow doesn't fire automatically for certain users

    Ok, I haven't got as far as triggering the workflow's through code, but it is possible through the Workflow Manager. This code just iterates through an Items workflows and deeper in displays the tasks that have been created..

    I'm using this in a webPart, so I'm using context for Site and Web. Hopefully this should give you a starter for using the workflowManager object. there's quite a lot of info in the SDK, thats where i got the majority of how to do this from.

    Paul.

    SPSite site = SPContext.Current.Site;

    SPWeb web = SPContext.Current.Web;

    SPWorkflowManager wfManager = site.WorkflowManager;

    SPWorkflowCollection workCol = wfManager.GetItemActiveWorkflows(item);

    //First we check there are active workflows on this item.

    if (workCol.Count >= 1)

    {

    foreach (SPWorkflow activeWorkflow in workCol)

    {

    SPWorkflowTaskCollection taskCol = activeWorkflow.Tasks;

    Do stuff!!######

    }

    }


    www.myfatblog.co.uk
    MCTS: WSS 3.0
    MCTS: MOSS 2007
  •  05-15-2008, 5:57 PM 10769 in reply to 10765

    Re: Workflow doesn't fire automatically for certain users

    Just found a post on one of the MSDN forums that uses the following VB to start a workflow, so not very hard to come up with the C# equivalent and take it further with a little bit of error checking around the Parent list workflow associations.

    Dim workflow As SPWorkflow

    workflow = manager.StartWorkflow(item, item.ParentList.WorkflowAssociations(0), "", True)
    item.Update()


    www.myfatblog.co.uk
    MCTS: WSS 3.0
    MCTS: MOSS 2007
  •  05-16-2008, 10:49 AM 10801 in reply to 10769

    Re: Workflow doesn't fire automatically for certain users

    So close with that last one!

    That sets the workflow to starting but after a period of time it just errors out. I can manually start the workflow without problem, but using the manager to start it just isn't playing ball.

  •  05-16-2008, 11:04 AM 10805 in reply to 10801

    Re: Workflow doesn't fire automatically for certain users

    Hmm, I'm guessing there must be more to it. Hopefully that's given you a good starting point, and I'll be very interested to know how you get on as I'm going to have to look at starting Workflows from code in the next phase of our project.
    www.myfatblog.co.uk
    MCTS: WSS 3.0
    MCTS: MOSS 2007
  •  05-16-2008, 11:26 AM 10815 in reply to 10805

    Re: Workflow doesn't fire automatically for certain users

    I'll keep prodding away at it and post up my findings.

    I created a VERY basic SPD workflow that just ended itself and logged to the history. That sits at starting for AGES, then finally kicked off. But the real one wont fire passed starting. It manually starts as I said though so I doubt it's broken.

    There's no initiation on it either, so no need to pass in data as far as I can see.

    I'm not sure if there's any mileage to be had in getting the workflow object that is created on the startworkflow event being fired. I've had a look and there doesn't seem to be much on offer from it unfortunately.

    It's just a simple email out some details workflow from SPD, so worst case scenario is just coding it into the timer job. But I'd rather keep it as a workflow because then I can let our business change guys go in and do the pointing and clicking to update any bits of the WF they want. Plus it'll make good sense to get it working now then document it for possible later use.

    However, if I don't come across any solutions by 3pm then it'll just have to wait as I'll be out of here as I've got a well earned week off!

  •  06-06-2008, 2:00 PM 11202 in reply to 10815

    Re: Workflow doesn't fire automatically for certain users

    I think I've finally solved this issue too.

    I think this line is where the important bit lies. oItem is the SPListItem, wfFiveDays is the workflow association:

    wfManager.StartWorkflow(oItem, wfFiveDays, "<workflowData></workflowData>")

    As you can see I've not used a blank eventData string, but rather I've put in the base tag with no information.

    Seems to solve the problem now.

  •  06-06-2008, 2:15 PM 11204 in reply to 11202

    Re: Workflow doesn't fire automatically for certain users

    Ah excellent news.. i guess that makes sense really if it's looking for some structured XML in that section. One to keep in the back of the memory methinks...
    www.myfatblog.co.uk
    MCTS: WSS 3.0
    MCTS: MOSS 2007
  •  06-09-2008, 8:46 AM 11222 in reply to 11204

    Re: Workflow doesn't fire automatically for certain users

    Exactly why I posted it here! Google is much better than my memory, and it handily indexes this place.
  •  06-09-2008, 9:34 AM 11225 in reply to 11222

    Re: Workflow doesn't fire automatically for certain users

    Hmm, how many years  until Google can index my brain... on second thoughts, do I want all of that in the public domain?
    www.myfatblog.co.uk
    MCTS: WSS 3.0
    MCTS: MOSS 2007
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems