Complete Workflow after approving all tasks

Hello everybody,
I'm face to a big problem with approval workflow OOTB. In my case, when one user from approvers approve his task. The workflow must be completed and we we din't need to wait other approvment. So, I developed an event receiver on Tasks Workflow list and I
checked the first approvment. After, that I approve all other tasks by code. The problem, the status of workflow is still equal to "In progress" despite the ending of all tasks ! It is strange.
This my code in event receiver of the list :
public override void ItemUpdated(SPItemEventProperties properties)
base.ItemUpdated(properties);
SPList list = properties.List;
SPWeb web = properties.Web;
SPList createDocument = DMSUtility.GetListByUrl(web, DMSConstants.LIST_CreateDocument);
string workflowItemId = string.Empty;
string taskStatus = string.Empty;
string taskID = string.Empty;
string taskworkflowStatus = string.Empty;
SPSecurity.RunWithElevatedPrivileges(delegate()
using (SPSite site = new SPSite(web.Site.ID))
using (SPWeb webSecure = site.OpenWeb())
if (list.RootFolder.Url.Equals((DMSConstants.LIST_CreateDocumentWorkflowTasks)))
//Get Tasks item
SPListItem itemTask = properties.ListItem;
if (itemTask["WorkflowOutcome"] != null && itemTask["WorkflowItemId"] != null)
workflowItemId = itemTask["WorkflowItemId"].ToString();
taskStatus = itemTask["Status"].ToString();
taskworkflowStatus = itemTask["WorkflowOutcome"].ToString();
taskID = itemTask["ID"].ToString();
if (taskworkflowStatus.Equals("Approved"))
SPListItem item = createDocument.GetItemById(Convert.ToInt16(workflowItemId));
// fetch workflow tasks
SPWorkflowTaskCollection wfTasks = item.Tasks;
int i=0;
foreach (SPWorkflowTask task in wfTasks)
// build a hashtable with the values to be changed to mark the task as complete
if (task["ID"].ToString() != taskID && task["Status"].ToString()!="Completed")
using (DisabledItemEventsScope scope = new DisabledItemEventsScope())
task.Web.AllowUnsafeUpdates = true;
task["Status"] = "Completed";
task["WorkflowOutcome"] = "Approved";
task[SPBuiltInFieldId.WorkflowVersion] = 1;
task.SystemUpdate();
Hashtable ht = new Hashtable();
ht[SPBuiltInFieldId.Completed] = "TRUE";
ht["Completed"] = "TRUE";
ht[SPBuiltInFieldId.PercentComplete] = 1.0f;
ht["PercentComplete"] = 1.0f;
ht["Status"] = "Completed";
ht[SPBuiltInFieldId.TaskStatus] = SPResource.GetString
(new CultureInfo((int)task.Web.Language, false),
Strings.WorkflowStatusCompleted, new object[0]);
ht[SPBuiltInFieldId.WorkflowOutcome] = "Approved";
ht["TaskStatus"] = "Approved";
ht["FormData"] = SPWorkflowStatus.Completed;
// alter the task using a trick to prevent task lock issue
//AlterTask((task as SPListItem), ht, true, 5, 100);
SPWorkflowTask.AlterTask((task as SPListItem), ht, true);
while (!(bool)item.Tasks[i]["Completed"])
Thread.Sleep(1000);
task.Web.AllowUnsafeUpdates = false;
task.Web.Update();
i++;
Do you have any idea ?
Thanks.

Hi,
I have verified creating the simple approval workflow process.  Use the following two actions instead of setting workflow status to approved and stop the workflow.
In this scenario, when one approver approves the task, others task is marked as cancel and his task will be marked as approved and list item will be marked as approved.
And finally, one more thing, the approval process approvers must be in parallel
Hope this will resolve your problem.
Please mark as answered, if your problem resolved.

Similar Messages

  • My iPad ran out of battery completely.  After charging all night, it is 100%, but my apps won't start.  I can access email, Safari, etc.....just not game apps.  I have restarted it several times.  Thanks!

    My iPad ran out of battery completely.  After charging all night, it is 100% however I cannot get my apps to work.  I can access Safari, email, etc., but cannot get game apps, etc.  I have restarted it a couple of times.  Any help?  Thanks!

    Try downloading any free app from thee store and then re-try your apps - the free app can then be deleted.
    If that doesn't work then try closing all your open/recently used apps completely : from the home screen (i.e.not with any app 'open' on-screen) double-click the home button to bring up the taskbar, then press and hold any of the apps on the taskbar for a couple of seconds or so until they start shaking, then press the '-' in the top left of the each app to close them, and touch any part of the screen above the taskbar so as to stop the shaking and close the taskbar.
    A third option is a reset : press and hold both the sleep and home buttons for about 10 to 15 seconds (ignore the red slider), after which the Apple logo should appear - you won't lose any content, it's the iPad equivalent of a reboot.

  • WS14000044: avoid loop in Completion workflow usage if all lines not compl

    Dear all,
    I have a question around the detailed usage of Workflow WS14000044: Completion workflow.
    Here is my case:
    A requisitioner creates a SC with complete items from catalog and also incomplete one's in free text (because not in his catalogs)
    The approval will be a line item cost center approval (n-level line item implemented via BADI).
    However prior to this cost center approvals, a purchaser needs to be involved for the incomplete lines being:
    - free text
    - no price
    the reason is that the purchaser has more extended catalogs and will replace some free texts by catalog items not accessible by the requisitioner
    or will give a price estimation to be able to have a more accurate cost center approval (which is multilevel and based on the value of the item line).
    Then my idea was to use the completion workflow for it.
    But my question is as when going to the purchaser this one is not replacing necessarily all the free-texts, then the user receive the changes and validate them and then the standard start conditions of this workflow that include free text evaluation will retrigger this workflow again and again and again.
    1)Is this correct?
    2) If not why?
    3) And what must be the starting condition of the completion workflow and n-level approval workflow to avoid the loop?
    Thanks in advance
    RD

    Thanks for the guidance, but I have additional questions:
    0) Based on your answer I suppose you did not implemented it anywhere (in standard)like this? Correct?
    1)For the incomplete item flag, you said "This flag is false as soon as you get out of the completion WF." is that always the case or is it only when the Purchaser as set a price?
    2) In summary free text item condition for the Completion Workflow is only usefull if you are sure to convert all lines to Catalog items. Correct?
    3) Coming to you proposition you loose then the possibility to approve your changes by the user like in completion workflow? Or how do you set-up the n-level approval workflow to have the requisitioner himself involved?
    4) Can somebody help to find the FM to find the purchaser of the corresponding PGr?
    5) How can I handle in the n-step approval workflow step if I have a purchasing Group with more than 1 purchaser?
    Thanks
    RD

  • How to automatic complete workflow after 3 weeks ago ?

    Hi all,
    I have one problem about workflow in SAP.
    I have the workflow that have one agent to assigned.
    How can I setup workflow to automatic complete if agent don't process task within 3 weeks ?

    Hi,
    Check whether the background job SWWDHEX is configured and its running for each 3 minutes.
    Also if you set the deadline as 3 minutes's, then you have to wait for some more 3 mins. Once the deadline reached the background job will execute the step with in three minutes. Check transaction SWWA. Here you can set the time interval for deadline job SWWDHEX.
    Then in the Activity step once the deadline is set, then select the modeled deadline in the action field. So that it will create a new
    branch in the wok flow template.
    For testing purpose, Just create a send mail step in the new branch and wait for ten minutes. Deadline will be reached and the mail will send to the inbox.
    Thanks.

  • Start PO workflow after approved from first level

    Hi Guys,
    I have i typical requirement i my knowledge its not possible.
    What exactly has happened is that after upgrade BUS2012 event linkage was not active and there where no workflow got triggered for PO approval
    But the line manager have gone and approved the POu2019s from ME29N now for the next level they are asking to send the workflow as we have activated the linkage.
    Any idea how can we start the workflow from that point again.
    Atul

    Hi Atul,
    In production how many workflow's are there like this?
    Its small amount of workflow's then you can again manually trigger the workflow using SWUE[You should pass the object key as purchase order number] and Complete the first level of workflow.
    So it will be go for Second level of Approval.
    If you have large amount of workflows that are already Triggered in production, then you have to discuss with your client about the issue.
    Thanks,
    Viji.

  • Difference between Due Date for All Tasks and Duration per task in an approval workflow

    Hello,
    I'm starting to read up and learn about approval workflows in Designer 2010.  I am confused by the fields "Due Date for all Tasks" and the "Duration per task".  I understand that the Due date for all Tasks is the date that all
    of the tasks in the workflow must be completed by.  And I understand that the duration means each task has x number of days to complete.
    But I dont know whey we need them both.  If I have the task duration set to two days and there are 3 tasks involved, then wouldn't the due date be 6 days from the start?  Why would I have a due date for all tasks that is completely different than
    the sum of the duration of days for each task? 
    Please help shed some light!

    Hi Michelle,
    Due date for all tasks, this setting specifies the date by which all tasks are due. It’s used for serial and parallel
    task.
    Duration per tasks, this setting specifies the date by which an individual
     task is due, it’s used for serial workflow participants.
    Note, when you create an approval workflow, select task process participants(approvers oob approval workflow), we can also
    select once at a time(serial) or all at once(parallel).
    For more information, see
    http://office.microsoft.com/en-us/sharepoint-server-help/use-an-approval-workflow-HA101793831.aspx
    Best Regards.
    Kelly Chen
    TechNet Community Support

  • Sharepoint 2013 designer workflow auto approve task after due date is passed

    sharepoint 2013 designer workflow auto approve task after due date is passed.
    Could we approve the task automatically once due date is apssed?
    MCTS Sharepoint 2010, MCAD dotnet, MCPDEA, SharePoint Lead

    Hi Amit,
    If your task is created by a workflow (first) and stored in a separate task list, you can create another workflow on this particular task list, then each workflow instance would check if current task is expired (not approved/rejected), then
    determine if update current task's "Task Outcome" as approved (and update task status as complete), and then create a retention policy on this paricular task list to trigger the workflow on due date .
    Thanks,
    Daniel Yang
    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]
    Daniel Yang
    TechNet Community Support

  • How to reopen completed workflow approval tasks?

    Hello - we are using OOTB approval workflows associated with a SP list. If a task is in "completed" status because the approver it was assigned to approved it, but it's not actually completed because the user approved it prematurely in error, how
    can I reopen the task?
    Thanks,
    Chris

    Hi Chris,
    We cannot reopen the task to approve or reject it again even thought we restore the task to a version before completed. Because once the task is in "Completed" status, it will be locked by the workflow and cannot be edited.
    For a workaround, you can start the approval workflow manually  and approve or reject it again.
    Thanks,
    Eric
    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]
    Eric Tao
    TechNet Community Support

  • Workflow in Project server 2013 online not going particular stage after Approval

    Hi All,
    i have created workflow using sharepoint designer 2013 for project server 2013 online. and i have also set the approver after the first stage. when i create a project using this workflow, project is created successfully and the approval task also go for
    a approval to specific user. and i have set the property that after approval it has to go on specific stage. but the problem is when user approve the task it shows approved but my stage in workflow is remain same. it is not going to any stage. 
    i don't know why this type of problem is occur. 
    FYI, i have created same workflow for Project server 2013 on premise(Which is installed in my server) and
    it is working fine but when i want to deploy this workflow in
    project server 2013 online its giving error.
    so please help me to solve this type of issue.
    Thanks

    I am also experiencing issues with this.  After the approval task is completed, the Workflow gets cancelled with the following message
    RequestorId: 60d96368-4cb4-b059-8086-604972a92e60. Details: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. at Microsoft.Activities.Hosting.Runtime.Subroutine.SubroutineChild.Execute(CodeActivityContext context)
    at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager
    bookmarkManager, Location resultLocation)
    All other desired workflow actions work as expected.  Emails are sent, project is moved from stage to stage, however as soon as the workflow approval task is completed, either Approved or Rejected, the Internal Status is changed to Canceled and the
    workflow fails.
    What is interesting is when the Approval task is completed, the approver will receive an email notification that the task was CANCELLED or DELETED....
    not COMPLETED, which is what would be expected.
    Has anyone seen this - any potential resolution?

  • Is there a way to allow setting of "Due Date for All Tasks" to current date in OOB Workflow

    Is there a way to allow setting of "Due Date for All Tasks" to current date in OOB Workflow
    I need to set it today because there are tasks that is needed to be completed on the same day.
    Is there a way without modifying the page/form. like a configuration or something?
    ----------------------- Sharepoint Newbie

    Hi ,
    As Ajeet said,  for implement your requirement, you can change the data validation on the Due data field.
    You can do as the following :
    Open the site with SharePoint Designer 2010
    Click on Workflows on the left launch, then find ‘Approval-SharePoint 2010’, click on it
    On the Forms section, click ‘ReviewApproval_***.xsn’
    Then you can find Due Data for All Tasks, and change the validation
    In addition, if you create an approval workflow with SharePoint Designer, you can use a specific date, it contains hour and minute.
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • Obtaining approver of task process in 2013 workflow

    Given a 2013 workflow where we start a task process, how can one get the user who approved the task process, assuming that the task process ending condition is one that requires the choice of one user (namely the first/specific response outcome types)?
    My goal is to use this later in the workflow.

    depending on the conditions of the task (one approver? multiple approvers? etc), what you can do is create a variable in the workflow, then drill into the task activity, and go into the task completion steps, and populate the workflow variable with the
    task variable of last modified.
    Scott Brickey
    MCTS, MCPD, MCITP
    www.sbrickey.com
    Strategic Data Systems - for all your SharePoint needs

  • Adding one more participant to approve the task in workflows

    Hi All,
    I'm having a requirement of adding the adding one more workflow user for approving the task. How to add one more workflow user in the human and allow him to approve the task which has been already approved by another workflow user, means it is hierarchical approval.
    First the task has been approved by assignee then finally the task has been approved by the approver who has admin rights.
    Regards,
    CH

    Hi,
    I have added the users but i need to approve the same task for twice then it is propagating the data to the other end. Is there any hierarchy that we have to
    define for the user inside human task.
    Everytime I'm approving the request for twice. How to approve the request for only one time.
    Regards,
    CH

  • Code for Custom Workflow to auto approve the task

    Hi All,
    Can any body help me with the java code to complete the Auto Approval Task.in OIM 11.1.1.5.
    Thank you

    1. Get the requester information from the payload. (In the Oracle sample the request Id is brought from the payload, similarly you can get the requester id and etc).
    2. Get the target user information from the payload along with target user's manager.
    3. Set the data from the two above into global variables and copy them into your .task variables.
    4. In the task use two serial stages and inside the stage use the skip rule condition with the variables from step 3.
    -Bikash

  • SharePoint Task List using Workflow for approver chain, gathering information from another list.

    What I have is a Custom List, that got the following fields for each item. 
    ApplicationName(SingleText) OwnerApproval(Person) ManagerApproval(Person) InstallExeuction(Person)
    Example data:
    | ApplicationName: Photoshop
    | OwnerApproval: Mister Blue
    | ManagerApproval: Mister Red
    | InstallExecution: IT Group
    What I have now then, is a task list as well. Where the user can press new task, and type in their PC name (singletext) and a dropdown menu to choose what application they want, for instance Photoshop.
    I'm not trying to make a workflow that starts when a new item is created to send an email to the OwnerApproval set for this specific application, Photoshop, if he approves it, a new email should be sent to ManagerApproval specific application, Photoshop.
    And if the last person ManagerApproval accepts it, a last email should be sent to InstallExecution, which if this person approves the task is marked as completed.
    I've been trying for mad now using SharePoint Designer and I almost got it to work. 
    Can anyone help me? I'm going mad here, I have VERY LIMITED knowledge in sharepoint designer.

    Hi Plankton,
    To achieve this goal, we can create with three Start a task process steps in the workflow and the workflow needs to be set to start when an item is created.
    For example, the custom list is called Custom, and the task list is called Task Custom.
    We can use the Task Status column for showing as Rejected or Excuted/Installed based on the users’ approval, so we need to add Rejected and Excuted/Installed values to the Task Status column. (same settings for Custom:ManagerApproval and Custom:InstallExecution
    as Custom:OwnerApproval with their own column value)
    Best regards.
    Thanks
    Victoria Xia
    TechNet Community Support

  • Outlook error when completing workflow task.

    Hi,
    Outlook error when completing workflow task.    I am receiving a "This task could not be completed at this time" error message in Outlook 2010 when completing a SP Approval workflow by using the "Open this Task" button
    in the ribbon.
    Please let me know the resolution for this issue.
    Thanks & Regards,
    Sasidhar K

    Hi Sasidhar,
    I'd first suggest installing any available updates on both Outlook and SharePoint sides for the issues related with Outlook integrated with SharePoint,
    Also, please take a look at this thread which disscused the same issue and see if it helps. <Steve_MTC> had a good summary of his findings:
    http://social.technet.microsoft.com/Forums/en-US/7a81aa4f-077b-4954-a110-7595169477e2/outlook-error-this-task-could-not-be-completed-at-this-time-when-completing-sp-approval-workflow?forum=sharepointgeneralprevious 
    You might also want to seek assistance in the forum of
    SharePoint, other partners who read the forums regularly can share their knowledge.
    Regards,
    Ethan Hua
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

Maybe you are looking for

  • Download from ALV grid to PDF format

    hai Friends!    plz tell me how can i download from ALV grid to PDF format.. send me some sample codes

  • Creative Cloud subscription help?

    I've found it impossible to contact Adobe via phone, so if anyone can help with this it would be fantastic! I'm using DPS and Edge software at the moment and I'm thinking of subscribing to Creative Cloud. I'm currently on a DPS Pro subscription but I

  • How can I install Photoshop Elements 9 on a laptop with no CD drive?

    I bought Photoshop Elements 9 couple of years ago and it's fine, I now have a new, smaller laptop with no CD drive and I have no idea how to install the Photoshop CD I already own, any suggestions?

  • Some comments on PDFs are not printed

    Hello, I've noticed that when making comments in Acrobat XI Pro, some of the comments are not printed as they are shown on the screen. For example, on one document I have a text box with two lines of text in it, but only the border of the text box an

  • Error in goods transist

    I am getting the error when I am going to do the goods in transit .I got the error .this is the path /GLB/RGTFC00_M2MCOGS >Configuration > Customize Postings > Goods in transit can anyone tell me  the solution.I am sending this error no relationship