質問

マイタスクリストには、次のフィールドがあります。

1)開始日
2)期限
3)による調査

Visual Studioのワークフローを通して、以下のシナリオを達成したい。どれでも私に使うべきな行動がどの行動になるべきという考えを教えてください。

注:ここではタスクリストにすでに割り当てられています。ワークフローでアクティブ化されたタスクアイテムを取得して電子メールを送信し、もう一度以下の手順を実行する必要があります。

  1. タスクが作成されたときに(ユーザー)から送信された調査に電子メールを送信します。

  2. タスクが期日から週のときに送信された調査に電子メールを送信する(タスクが完了していない場合)

  3. タスクが期日から2日(タスクが完了していない場合) の場合、(ユーザー)から送信された調査に電子メールを送信します。

  4. 期日(タスクが完了していない場合) で送信された調査にメールを送信する(ユーザー)。

  5. タスクを「完了」としてマークし、タスクが期日を越えて(ユーザ)許可を除外し、完了していない を除いて、検索を除去してください。


    は私が試したシナリオです。

    ワークフローデザイナ:Workflowサンプル OnWorkflowActivatedCode:

      private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e)
            {
                try
                {
    
    
                    CurrentDate = String.Format("{0:MM/dd/yyyy}", CTDate);
                    SPListItem CurrentWorkflowitem = onWorkflowActivated1.WorkflowProperties.Item;
                    _ItemListDuedate = DateTime.Parse(Convert.ToString(CurrentWorkflowitem["Due Date"]));
                    _ItemSurveySubmittedBy = Convert.ToString(CurrentWorkflowitem["Survey Submitted By"]);
                    _ItemStatus = Convert.ToString(workflowProperties.Item["Status"]);
                    SPFieldUserValue SubmitteduserValue = new SPFieldUserValue(CurrentWorkflowitem.Web, _ItemSurveySubmittedBy);
                    SubmittedUserLastName = SubmitteduserValue.User.Name.Split(',').LastOrDefault();
                    SubmittedUserEmail = SubmitteduserValue.User.Email;              
                }
    
                catch (Exception ex)
                {
    
                    SendEmailToAdmin(ex.Message);
                }
    
            }
    
    .

    ワークフローステータスループ:

    private void WorkflowStatus_Loop(object sender, ConditionalEventArgs e)
            {
               bool workflowstatus= CompareCurrentDate_DueDate(_ItemStatus, _ItemListDuedate);
               if (workflowstatus)
               {
                   e.Result = true;
               }
     private bool CompareCurrentDate_DueDate(String CurrentStatus, DateTime ListDuedate)
            {
                try
                {
                    if (CurrentStatus != "Completed")
                    {
                        CTDate = DateTime.Parse(Convert.ToString(DateTime.Now));
                        int Cmin = CTDate.Minute;
                        int Listmin = ListDuedate.Minute;
                        diff = Cmin - Listmin;
                        //TimeSpan age = ListDueDate.Subtract(CTDate);
                        // diff = Convert.ToInt32(age.Days);
                        if (diff > 48)
                        {
                            datechk = false;
    
                        }
                    }
                    else
                    {
                        datechk = false;
                    }
    
                }
                catch (Exception ex)
                {
                    datechk = false;
                    SendEmailToAdmin(ex.Message);
    
                }
                return datechk;
            }}
    
    Code to check Status 
     private void codeToCheckStatus_Initial(object sender, EventArgs e)
            {
                try
                {
    
    
                    String Duedate = String.Format("{0:MM/dd/yyyy}", _ItemListDuedate);
                    Remainder1 = (Boolean)onWorkflowActivated1.WorkflowProperties.Item["Remainder1"];
                    Remainder2 = (Boolean)onWorkflowActivated1.WorkflowProperties.Item["Remainder2"];
                    Remainder3 = (Boolean)onWorkflowActivated1.WorkflowProperties.Item["Remainder3"];
                    InitialMail = (Boolean)onWorkflowActivated1.WorkflowProperties.Item["InitialMail"];
    
                    if (InitialMail == true)
                    {
                        Email_Body = "Please complete the below survey before the Due date has completed. ";
                        Email_Subject = "Survey Task with Title " + onWorkflowActivated1.WorkflowProperties.Item.Title + "has been assigned";
                        HTMLBODY = PopulateBody(SubmittedUserLastName, Duedate, Email_Body, "TaskList");
                        SendEmail(Email_Subject, SubmittedUserEmail, " ", HTMLBODY);
                        updatelist("InitialMail", false);
                    }
                    if (diff == 41 && Remainder1 == true)
                    {
                        Email_Subject = "Week Remainder Email for the Task " + workflowProperties.Item.Title;
                        Email_Body = "The Task is due kindly act on it";
                        HTMLBODY = PopulateBody(SubmittedUserLastName, Duedate, Email_Body, "TaskList");
                        SendEmail(Email_Subject, SubmittedUserEmail, " ", HTMLBODY);
                        updatelist("Remainder1", false);
    
                    }
                    if (diff == 44 && Remainder2 == true)
                    {
                        Email_Subject = "Two Day Remainder Email for the Task " + workflowProperties.Item.Title;
                        Email_Body = "The Task is due kindly act on it";
                        HTMLBODY = PopulateBody(SubmittedUserLastName, Duedate, Email_Body, "TaskList");
                        SendEmail(Email_Subject, SubmittedUserEmail, " ", HTMLBODY);
                        updatelist("Remainder2", false);
    
                    }
                    if (diff == 45 && Remainder3 == true)
                    {
    
                        Email_Subject = "Same Day Remainder Email for the Task " + workflowProperties.Item.Title;
                        Email_Body = "The Task has been update as completed and you dont have permissions for the same";
                        HTMLBODY = PopulateBody(SubmittedUserLastName, Duedate, Email_Body, "TaskList");
                        SendEmail(Email_Subject, SubmittedUserEmail, " ", HTMLBODY);
                        //SPListItem wfitem = workflowProperties.Item;
                        //wfitem["Remainder3"] = false;
                        //wfitem["Status"] = "Completed";
                        //SPRoleAssignmentCollection SPRoleAssColn = wfitem.RoleAssignments;
                        //for (int i = SPRoleAssColn.Count - 1; i >= 0; i--)
                        //{
                        //    SPRoleAssignment roleAssign = SPRoleAssColn[i];
                        //    SPRoleAssColn.Remove(i);
                        //}
                        //wfitem.Update();
    
                        updatelist("Remainder3", false);
    
                        SPListItem wfitem = workflowProperties.Item;
                        wfitem["Status"] = "Completed";
                        wfitem.SystemUpdate();
                    }
                }
                catch (Exception ex)
                {
                   // datechk = false;
                    SendEmailToAdmin(ex.Message);
    
                }
    
            }
            private void updatelist(string field, Boolean value)
            {
                SPListItem wfitem = workflowProperties.Item;
                wfitem[field] = value;
                wfitem.SystemUpdate();
            }
    
    .

    私はデザイナーの再利用可能なワークフローで試しました。添付されているのは私のデザイナーのワークフローです。下に述べたように、再利用可能なワークフローのために行くとき、我々は更新されたステータス列を取得することはできません。タイトルを使ったとき、ワークフローはうまく機能しています

    Designerワークフロー

役に立ちましたか?

解決 3

I was able to achieve this by creating a calculated column which has the status modified. During this time I am delaying the workflow for 2 days in the workflow.

At this time I am checking this calculated column with current item. If status is completed I am ending the workflow.

他のヒント

If a understand you query, You can probably use some custom timer job which will iterate through all the open tasks and based on your custom logic it will send emails to the specific users. You can send email by SPUtlity.Send email and you can even end the workflow programatically from this/

This is only a another solution to your problem.

I know it's not VS solution, but for exactly that kind of scenarios I use HarePoint Workflow Scheduler.
It's free for commercial use and extremely easy to use as well.

What you need to do is to create a simple workflow in SharePoint Designer that checks if Today is the day you require (for example DueDate-2).
If yes, do whatever needs to be done, if not then stop the workflow.
And schedule this workflow in HarePoint to be run once a day at 1am (for example).

ライセンス: CC-BY-SA帰属
所属していません sharepoint.stackexchange
scroll top