Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm adding documents to a records library by clicking 'Add new item', upload the document, set the metadata, then click OK. Up until now, I've been working with this workflow in my VM & local environment. While debugging, my break point in the onWorkflowActivated method would not get hit until I set the properties and click OK.

Now, I am deploying the solution into production, which is a completely different environment. I'm finding that the workflow is now starting when I initially upload the document, before setting any metadata. Because of this reason, no properties are being set in my workflow.

Two questions:

  1. Is this expected behavior? If so, why wasn't it occurring in my dev environment?
  2. How do I get around this? If I enter the onWorkflowActivated method before the properties are set, how do I stop and wait for the properties to exist, then re-instantiate my workflowProperties object?
share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Yes, that's expected behavior from all that I've see because the workflow is firing on item creation, which is what you did when it finished uploading. The metadata screen is actually the EditForm. So you can trigger the workflow on item changed or put a reasonable pause on item creation before moving along with the workflow operations, that gives users enough time to enter the metadata.

share|improve this answer
    
I guess I understand that it is running as soon as the document is uploaded, but why did I not run in to this issue while developing in my VM? Is there a 'supported' way to perform a pause? Won't I have to re-hydrate my workflowproperties? –  Tim Gabrhel Sep 9 '11 at 18:59
    
There is an out of the box pause for duration activity that could be set to like 5 minutes. AS to why you didn't see it in development, I'm not sure, I don't sit in VS, I've just experienced it in working with libraries with required metadata and workflows associated with them. –  PirateEric Sep 9 '11 at 19:15
    
Dang...Is there a cleaner way of doing this without setting an arbitrary delay? Granted, something like 5 minutes would probably suffice, but I'd like the workflow to be 'running' and all the user to progress it's stage immediately after upload. –  Tim Gabrhel Sep 12 '11 at 13:15
    
You should be able to do something like Wait for a change in a field. Look for one of the required metadata fields to not be empty and then continue on. You might be able to get some "preprocessing" done up until the point the required metadata is needed. –  PirateEric Sep 12 '11 at 13:28
    
Thanks for the tip. I've added a while activity that holds a variable for the workflowProperties.Item.Title, with an onWorkflowItemChanged activity within. This should suffice. –  Tim Gabrhel Sep 12 '11 at 16:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.