Out of the box workflow failed on start when started programatically

I have an approval workflow (out of the box) associated with a list and need to start it for some items programmatically when some conditions are met. 
My application runs under an account which is a farm admin. I do have another user dedicated to start workflows. I'm using the code below but it always results in a 'failed on start'  with these errors
2/27/2015 4:54 PM
Workflow Cancelled
System
Account
Workflow 'WorkflowName' was canceled by System Account.
2/27/2015 4:54 PM
Error
System
Account
'WorkflowName' failed to start.
Code is : 
SPUserToken userToken = null;
            using (SPSite site = new SPSite("SiteName"))
                using (SPWeb web = site.OpenWeb())
                    site.AllowUnsafeUpdates = true;
                    web.AllowUnsafeUpdates = true;
                    userToken = web.AllUsers["WorkflowAccount"].UserToken;
    site.AllowUnsafeUpdates = false;
                    web.AllowUnsafeUpdates = false;
            using (SPSite site = new SPSite("SiteName", userToken))
                using (SPWeb web = site.OpenWeb())
                    site.AllowUnsafeUpdates = true;
                    web.AllowUnsafeUpdates = true;
                    SPWorkflowManager workflowManager = web.Site.WorkflowManager;
                    SPList list = web.Lists["LibName"];
                    SPListItem item = list.Items[1];
                    SPWorkflowAssociationCollection associationCollection = list.WorkflowAssociations;
                    foreach (SPWorkflowAssociation association in associationCollection)
                        if (association.Name == "WorkflowName")
                            association.AutoStartChange = true;
                            association.AutoStartCreate = false;
                            association.AssociationData = string.Empty;
                    site.WorkflowManager.StartWorkflow(item, association, association.AssociationData);
    break;
site.AllowUnsafeUpdates = false;
                        web.AllowUnsafeUpdates = false;
Is there any requirement on who can create the workflow? I can control who creates if I absolutely have to
Any help/clues/directions appreciated.

Hi LNFei,
To troubleshooting the issue, I recommend to follow the steps as below:
1.Start the workflow manually to check whether it works.
2.Use another account not System Account to check whether it works.
3.Publish the workflow as a different user (rather than System Account).
4.Deactivate and Reactive the “Workflow” Feature.
5.Check other workflows on other lists/libraries could work well.
6.Create a simple workflow having only one activity which will log history only, check if it works well.
Best Regards,
Wendy
TechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
[email protected]

Similar Messages

  • Where is the SP 2010 out of the box workflow status value stored?

    I created an out of the box Approval - SharePoint 2010 workflow (TEST1) on a custom list. When I created this out of the box workflow, I specified a name for the task (TEST1 Tasks) and history (TEST1 History) list. 
    The workflow is creating tasks, sending emails, and the task emails lead me to a screen where I can approve or reject the requests.
    However, TEST1 - the list that contains the items created - doesn't have a status column.  The TEST1 Tasks has a status column. But I would prefer the people working with the workflow just look at TEST1 and not the Tasks or History lists.
    What is the preferred way to create one of these list workflows so that the admins only have to look at the specific tasks that have been submitted and they can see which have been approved or not?
    Thank you
     

    Thank you for your reply. Initially, I didn't have content approval turned on, had workflow approval turned on, but didn't have a status column. I also had an error in the history list that the status could not be created.
    When I turned on the content approval, then I got a status column, but now my list has a warning across the top telling the user that their request won't be public until approved.
    I don't really WANT a document approval workflow. But I don't see how to set up what I do want.
    What I need is a simple custom list - a few lookup columns, the rest static data columns, that describe an action that is being requested. That request (ala the list item) is what needs to be approved or rejected. There is no publishing needed in this workflow.
    The approval workflow was the closest I could see for setting up such a simple request workflow.

  • How can I replace the out of the box photos with my own when music is playing?

    How can I replace the out of the box photos with my own when music is playing?

    Welcome to the Apple Community.
    Select any photos you want to share with the Apple TV using the iTunes advanced menu (using iPhoto is the better option but a folder will work). Once all the photos you want are shared, go to settings > screensaver on the Apple TV and choose which of those shared photos you want to use with your screensaver.

  • How can I display a SP 2010 out of the box workflow's task assignees via powershell?

    There are days where one of the 250+ workflows at the site has attempted to send email to someone no longer at the company.
    I would like to find a way to go through the farm and display all the list URLs that have workflows, and the mail addresses associated to the workflows.
    This way I can track down the workflows that need to be updated to remove the missing users.
    I have started a bit of script to do this. In my script, I just had a site collection - I figured that if I can get that to work, then surely wrapping another loop for the rest of the farm won't be bad. 
    However, for some reason, I am not seeing the output that I expected to show the mail addresses.
    I am hoping a different set of eyes might see what I am missing. It was my understanding that the AssociationData property was XML that contained information about the assignees for tasks, the carbon copy list, etc.
    Maybe I misunderstood something that I read?
    $outLoc = "d:\temp\wfdata.txt"
    $web = Get-SPWeb -Identity "http://myfarm/sites/it/"
    foreach ($list in $web.Lists)
     $associationColl=$list.WorkflowAssociations
     foreach ($association in $associationColl)
           $association.AssociationData | Out-File $outLoc
    $web.Dispose()
    I want to thank you for the helpful tips that so often appear on this list. They help me when I am reading over old threads to figure out what to do. I am hoping that tips on this thread will likewise be helpful.

    Hi,
    With
    SPWorkflowAssociation.AssociationData property, we can get the assignees’ information. Your script can
    be able to retrieve a XML format data which contains the user name we need:
    So the next step would be getting the user name by parsing the XML data we got.
    The two links below will show how to parse XML with PowerShell:
    http://stackoverflow.com/questions/18032147/parsing-xml-using-powershell
    http://blogs.technet.com/b/heyscriptingguy/archive/2012/03/26/use-powershell-to-parse-an-xml-file-and-sort-the-data.aspx
    With the user name, we can get the
    Email property of an user with the scripts as the link below provided:
    http://davidlozzi.com/2012/03/07/using-powershell-to-access-sharepoint-sites/  
    Best regards
    Patrick Liang
    TechNet Community Support

  • Out of the box workflow of type Approval - SharePoint 2010 not recording approver comments

    When I am implement my approval workflow, two new fields are created - Approval Status and Approver Comments.
    The Approval Status field gets a value of either Rejected, Pending, or Approved.
    The Approver Comments is not getting any value, even though I am entering comments in the popup approve workflow task and those comments are appearing in the emails sent.
    Why do the comments not show up in the item's Approver Comments column?

    Hi,
    With
    SPWorkflowAssociation.AssociationData property, we can get the assignees’ information. Your script can
    be able to retrieve a XML format data which contains the user name we need:
    So the next step would be getting the user name by parsing the XML data we got.
    The two links below will show how to parse XML with PowerShell:
    http://stackoverflow.com/questions/18032147/parsing-xml-using-powershell
    http://blogs.technet.com/b/heyscriptingguy/archive/2012/03/26/use-powershell-to-parse-an-xml-file-and-sort-the-data.aspx
    With the user name, we can get the
    Email property of an user with the scripts as the link below provided:
    http://davidlozzi.com/2012/03/07/using-powershell-to-access-sharepoint-sites/  
    Best regards
    Patrick Liang
    TechNet Community Support

  • Not able to start out of the box approval workflow programmatically

    We have a requirement to start an out of the box workflow from a .NET web service.
    We are using the StartWorfklow method:
    wfManager.StartWorkflow(item, association, association.AssociationData
    we are getting the below error message at the above line of code: Attempted to perform an unauthorized operation.. Data: System.Collections.ListDictionaryInternal
    Then, we tried:
    SPSecurity.RunWithElevatedPrivileges(delegate()
            wfManager.StartWorkflow(item, association, association.AssociationData,
    SPWorkflowRunOptions.Synchronous);
    Now, the workflow got canceled automatically with "Failed on Start" status. In the "Workflow History", it is showing 2 records with "was canceled by System Account." & "failed to start" in the description
    column.
    Please advise.

    Hi Zhengyu,
    1. I've already done that:
    a) when "SPSecurity.RunWithElevatedPrivileges(delegate()"
    is used, there are no errors showing up and code gets executed. However, the workflow failed to start.
    b) When I don't use elevated privileges, the code is showing an error (Attempted to perform an unauthorized operation.. Data: System.Collections.ListDictionaryInternal) when
    it tries to start the workflow (StartWorkflow method).
    2. The workflow starts with no issues through UI. I tried it using "System Account" and another account.
    3. I tried also "Collect Feedback" workflow template. Same results...
    You can find the code below:
    public
    stringStartItemWorkflow(stringsitePath,
    stringlibraryName,
    stringfileName)
    stringreturnVal =
    String.Empty;
    stringwfName =
    "VPApprovalWF";
    SPUserTokentoken = GetSecurityToken(sitePath);
    try
    using(Microsoft.SharePoint.SPSiteportalSite
    = newMicrosoft.SharePoint.SPSite(sitePath,
    token))
    using(SPWebportalWeb
    = portalSite.OpenWeb())
                        portalWeb.AllowUnsafeUpdates =
    true;
    SPListlist = portalWeb.Lists[libraryName];
    SPQueryfileQuery =
    newSPQuery();
                        fileQuery.Query =
    String.Format("<Where><Contains><FieldRef
    Name='FileLeafRef' /><Value Type=\"User\">{0}</Value></Contains></Where>", fileName);
                        fileQuery.ViewAttributes =
    "Scope='RecursiveAll'";
    SPListItemCollectionlistItemCol = list.GetItems(fileQuery);
    SPWorkflowManagerwfManager = portalSite.WorkflowManager;
    SPWorkflowAssociationCollectionassociationCollection
    = list.WorkflowAssociations;
    if(listItemCol.Count > 0)
    foreach(SPListItemitem
    inlistItemCol)
    if(associationCollection.Count > 0)
    foreach(SPWorkflowAssociationassociation
    inassociationCollection)
    if(association.Name == wfName)
                                            item.Update();
                                            association.AutoStartChange
    =
    true;
                                            association.AutoStartCreate
    =
    false;
                                            association.AssociationData
    =
    String.Empty;
                                            StartWF(wfManager,
    item, association);
                                            returnVal +=
    "Workflow Started";
    break;
    else
                                    returnVal +=
    "No workflows are attached to the library.";
    else
                            returnVal +=
    "A file with the name provided doesn't exist";
                        portalWeb.AllowUnsafeUpdates =
    false;
    catch(Exceptionex)
                returnVal +=
    "Workflow not started, reason: "+
    String.Format("Source:
    {0}. Stack Trace: {1}. Inner Exception:{2}. Message: {3}. Data: {4}", ex.Source, ex.StackTrace, ex.InnerException, ex.Message, ex.Data);
    returnreturnVal;
    SPUserTokenGetSecurityToken(stringsitePath)
    SPUserTokentoken =
    null;
    SPSecurity.RunWithElevatedPrivileges(delegate()
                Microsoft.SharePoint.
    SPSiteportalSite =
    newMicrosoft.SharePoint.SPSite(sitePath);
                token = portalSite.RootWeb.EnsureUser(
    "DOMAIN\\ADMIN-USER").UserToken;
                portalSite.Dispose();
    returntoken;
    privatestaticvoidStartWF(SPWorkflowManagerwfManager,
    SPListItemitem,
    SPWorkflowAssociationassociation)
    SPSecurity.RunWithElevatedPrivileges(delegate()
                wfManager.StartWorkflow(item, association, association.AssociationData,
    SPWorkflowRunOptions.Synchronous);
    Thank you all for your help.
    Regards,

  • In search of assistance learning how to modify the mail message from an out of the box SP2010 approval workflow.

    So, I have found the article
    http://punaro.com/2012/01/derek/modifying-a-sharepoint-2010-workflow-email/comment-page-1/ which appears to walk through the process of modifying an out of the box workflow's mail message.
    However, there is a basic problem that I run into before I get started.
    I am logged into the system as a regular user (ie not a farm admin, etc.).
    I do, however, have full control on the site on which I am working.
    I create a custom list.
    I create a simple one step approval - sharepoint 2010 out of the box workflow.
    I start SharePoint designer and give it the URL of the list. It opens up and I see the various objects on the left side of the screen.
    I click right on the Workflows object - which is where the article says I will find the ability to copy and modify the workflow.
    All I see is "open", "open in a new tab" and "Pin".
    I selecdt open in a new tab - and I get a blank screen labeled workflows that says "There are no items to show in this view".
    So, I click on Lists and Libraries, then on the name of my custom list.
    When the list displays, the Workflows section of the page has a "Modified Workflow" displayed.
    When I right click on it, no menu is shown. When I click on the modified workflow, I get the workflow settings page for that workflow.
    I am trying to figure out how to create the copy of the workflow so that I can modify one of the mail messages in SharePoint designer.
    Is there someone who has some advice on how to find this copy and modify option?  Or perhaps a web site, web forum, article series, or book covering the topic?
    Thank you! 

    Hi lwvirden,
    According to your description, my understanding is that you want to modify the OOB approval workflow in SharePoint Designer.
    After opening the site in SharePoint Designer, just click Workflows in the left panel and then the workflows in the site will load in the right part.
    If you want to copy and modify the OOB approval workflow, then you need to right the approval workflow
    Approval – SharePoint 2010 under Globally Reusable Workflow. After that you will see the
    Copy and Modify button.
    Best regards.
    Thanks
    Victoria Xia
    TechNet Community Support

  • Can I use my iPhone 6 out of the box to take photos, before syncing it with my computer?

    I will be receiving a new iPhone 6 at the beginning an upcoming trip and would like to use the great camera on it to take photos. The problem is I won't have my computer with me during this trip. Will I be able to use my iPhone right out of the box to take photos, and when I sync my iPhone for the first time will I risk losing those photos? Thank you for the help.

    Will I be able to use my iPhone right out of the box to take photos
    Once you have activated the iPhone with a sim inserted
    when I sync my iPhone for the first time will I risk losing those photos?
    Yes unless you transfer Photos off iOPS device to your PC/Mac
    see this
    Import photos and videos from your iPhone, iPad, or iPod touch to your Mac or Windows PC - Apple Support

  • Out of the box approval workflow suddenly failed on start (retrying)

    SharePoint 2010. I've been using out of the box approval workflow for several month now. I did some minor changes to it, like to who and when emails should be send, but that's all.
    Then out of a sudden it stopped working. New request status is "Failed on start (retrying)". Sometimes (!) status is "In Progress", but no tasks are created. In both cases there is nothing on workflow history and error report is also empty
    (it even cause an error "Report contains no data").
    I'm sure that I didn't change anything in a workflow. The only think that I changed was an InfoPath form, but I only added there field "Created By", so I would see in calendar later who created this request. I couldn't see how this might affect workflow
    process.
    I'm confused as I don't even know where to start searching for the solution. Why this might happen? Any ideas are very welcome!

     In my list I have a multiple choice field which is not required. When it was
    blank my workflow was failing on start! This field was not involved in a workflow directly, I included it only in the email to approver. When I deleted it from an email everything was fine.

  • After the in place upgrade from SharePoint server 2007 to 2010, the out of the box approval workflow does not prompt for additional information after check in of a major version.

    I think it has to do with the interaction between Word, InfoPath, IIS, and /or SharePoint, but I cannot put my finger on it.  Maybe client integration or authentication settings?  I have looked at it in wireshark
    and have not seen anything glaring.
    Steps to reproduce the (working) behavior:
    Set up a document library in SharePoint 2010.
    Under versioning settings, make the following changes:
    Set Require Content Approval for submitted Items to Yes
    Select Create Major and Minor (draft) versions
    Set require checkout to Yes
    Create an out of the box “approval” workflow with the following settings:
    Start this workflow to approve publishing a major version of an item.
    I then create a new document. Save it.  check it in.  it is now version 0.1.
    I then open it again. check it out.  Make a change. Close and save it.
    Check it in.
    Publish major version:
    At this point a screen is presented to me to enter workflow parameters.  This screen comes up in Enterprise 2013 and MOSS 2007, but not the migrated version of 2010:
    This is what I need help with.  It should come up in 2010.  To fix it in 2013, I had to change the IIS bindings to only have 1 entry for a port.  I did this for 2010 and it did not work.
    Any help or ideas is very appreciated.  Thanks very much in advance.

    Hi Chris,
    According to your description, my understanding is that the approval workflow cannot work when the workflow was set to start to approve publishing a major version of an item after upgrading to SharePoint 2010.
    I recommend to check the approval workflow in Workflow settings of the corresponding library to see if the Start this workflow to approve publishing a major version of an item is checked.
    For test, I recommend to create a new OOB approval workflow and set it to start to approve publishing a major version of an item in the same library to see if the workflow can work.
    Thanks
    Victoria
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Victoria Xia
    TechNet Community Support

  • I can't see the workflow diagram in the out-of-the-box proposal workflow in Project Server 2010

    Hello,
    I created new project based on the template out-of-the-box proposal, but after that i can't see the following diagram ..

    Hi,
    To achieve this you can use Workflow Visualization webpart from Project Server 2010 Solution Starter Kit from
    here.
    Thanks !!!
    Sachin Vashishth MCTS

  • Out of the box sharepoint online 2013 workflow

    Hi All,
    I have a workflow that sends a email to a user after creating a new document.
    Now a want to attach a document to this email but this is not possible with the out of the box SharePoint 2013 solution. I use the SP 2010 workflow because I need to send a email to an external user.
    Is there a solution that I can use to attach a document to a email in a workflow?

    Not possible out of the box. Just curious why would you want to email someone files over the email? I think the logical way is to simply send the item link. This will show user the item details and attachments.
    Anyways, If that's the way you want to do it then check the following codeplex solution out.
    http://spdactivities.codeplex.com/
    I would still recommend you to send the current Item URL in the email instead of sending document as an attachment. 
    If this helped you resolve your issue, please mark it Answered

  • How do I start over and bring my MacBook Pro to a brand new out of the box state?

    I have a MacBook Pro with Retinal Display purchased in June 2012.  I have backed up once using Time Machine. How do I put it back to the brand new just purchased out of the box state? Any ideas?  I have done this with windows computers, but never a Mac.

    To restore your MacBook to factory settings, you have to use Internet Recovery. Follow the steps:
    1. Press Command, Option and R keys while your Mac is starting, and open Disk Utility.
    2. Select Macintosh HD in the sidebar, go to Erase tab and erase the disk.
    3. Close Disk Utility and reinstall OS X. This can take hours because your computer has to download OS X from the App Store.
    After restoring the computer to factory settings, open App Store > Purchases to download iMovie, iPhoto and GarageBand

  • Just started up my Mac Mini out of the box, using a USB windows keyboard, it will not recognize letters so I am unable to enter serial number.  Anything I can do to get the mini mac right out of the box to recognize the windows keyboard?

    Just started up my Mac Mini out of the box, using a USB windows keyboard, it will not recognize letters so I am unable to enter serial number.  Anything I can do to get the mini mac right out of the box to recognize the windows keyboard?  Do I have to buy an Apple Keyboard to get it to work right out of the box?

    Is this a normal USB keyboard or is there anything specialized about it? Does this keyboard require you to install any special software to use it on a Windows box? Or is it usually a plug & play keyboard?
    Normally if a Mac does not recognize a keyboard it asks you to press certain keys to identify the keyboard. What is happening on screen with this keyboard? What serial number are you referring to?

  • I have messed my MacBook Pro attempting to customize it. I am far from savvy with technology and I would like to erase and reset it to out of the box brand new and start over

    I have messed my MacBook Pro attempting to customize it. I am far from savvy with technology and I would like to erase and reset it to out of the box brand new and start over

    Polly,
    usually there are multiple models of MacBook Pro per model number, but in the case of your model number (A1502), there’s currently only one model for that model number: 13-inch Late 2013.
    To reset your MacBook Pro, you’ll need to boot into Recovery mode by holding down a Command key and the R key as you start it up. When the Mac OS X Utilities menu appears, select Disk Utility. On the left-hand side of the Disk Utility window, select your internal disk (most likely the top item of the list). On the right-hand side, select the Erase tab. For the Format dropdown, select “Mac OS Extended (Journaled)”. For the Name input box, “Macintosh HD” has traditionally been the default name — I don’t know if that’s still the case for the Late 2013 models. After that, press the Erase… button, and erase its entire internal disk. When it’s finished with the erasure, exit Disk Utility, and select Shut Down from the Apple menu. When you start it up again, OS X Internet Recovery will redownload Mavericks from Apple’s servers and reïnstall it on your internal disk. Once it has reïnstalled, run Software Update to get it up to date, and adjust the System Preferences to your taste.

Maybe you are looking for

  • Sun Java System Application Server8  could not start..using OSX

    I am having problems trying to run my application. When run the applicaiton it tries to deploy it but fails with a message that is could not start the applicaiton server. It suggests the fault could be port conflicts or corrupt domain.xml file. If I

  • Delay in displaying print dialog window

    When I click on 'print', in Reader (any version) there is a 90 second delay before the print window appears! This seems to be because Reader 'polls' all the printers in my list, before showing the window. I can make the problem disappear by deleting

  • Do you also experience lens flare with iPhone 4S?

    I got my iPhone 4S 32G white few days ago and it's been working fine. But when I take picture at night, I see some white dots which seem to be lens flares. It happens especially when pointing bright objects(such as streetlight) in the dark place. Do

  • Can't get rid of old icloud acount

    I created an icloud account some years ago but haven't used it in a long long time as I no longer use that email address.  The problem I have is that my shiny new iphone 5c which I registered this afternoon has backed itself up of my previous 3GS inf

  • Checksum wrong in Mathematica 8

    Hi everybody! I'd like to use Mathematica 8 on my x86_64 desktop but the installation goes wrong from the first step: ./Mathematica_8.0.1_LINUX.sh Mathematica Secured 8.0.1 for LINUX Installer Archive Verifying archive integrity. Error in MD5 checksu