Hello Gurus,

       I am looking to start a Sharepoint designer workflow programmatically. I 
have referred to a few useful blogs to  achieve this.


*         
http://www.moss2007.be/blogs/vandest/archive/2008/01/18/programmatically-start-workflow.aspx

*         
http://blogs.msdn.com/sumanc/archive/2008/08/16/starting-canceling-a-workflow-programmatically.aspx

Now,   whenever I run the code I get an error which says " Operation is not 
valid due to the current state of the object".
I've also gone through this post as well to re-structure my code,  
(http://howtocode.blogspot.com/2007/06/moss-splistitemupdate-throws-error.html),
 but the error keeps coming up whenever the workflow start code is initiated.  
Not really sure where the issue lies. Have you'll encountered this previously 
in your development experience ?

Below is the code snippet

SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    using ( MySiteWebApplication = new SPSite(photoLibrarySite))
                    {

                        using (web = MySiteWebApplication.OpenWeb())
                        {

                             picLibrary = 
(SPDocumentLibrary)web.Lists[photoLibraryList];
                             libraryRelativePath = 
picLibrary.RootFolder.ServerRelativeUrl;
                             libraryPath = 
MySiteWebApplication.MakeFullUrl(libraryRelativePath);

                             list = web.Lists[photoLibraryList];
                        }
                    }
                });

                MySiteWebApplication.AllowUnsafeUpdates = true;
                web.AllowUnsafeUpdates = true;

web.Site.WebApplication.FormDigestSettings.Enabled = false;

SPWorkflowAssociation associationTemplate = 
list.WorkflowAssociations.GetAssociationByName("SPD", 
System.Globalization.CultureInfo.CurrentCulture);

MySiteWebApplication.WorkflowManager.StartWorkflow(newItem, 
associationTemplate, "");

web.Site.WebApplication.FormDigestSettings.Enabled = true;



Thanks and Regards
Manish Shroff



________________________________
This email is intended for the named recipient only. The information contained 
in this message may be confidential, or commercially sensitive. If you are not 
the intended recipient you must not reproduce or distribute any part of the 
email, disclose its contents to any other party, or take any action in reliance 
on it. If you have received this email in error, please contact the sender 
immediately and please delete this message completely from any systems. 
Confidentiality and legal privilege are not waived or lost by reason of 
mistaken delivery to you.
_______________________________________________
ozmoss mailing list
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss

Reply via email to