4 Replies Latest reply: Mar 14, 2014 5:33 PM by Sruthi Deva RSS

    QMS API to create task

      Hello Experts,

       

      I am trying to create a task using QMS API. I am successful in creating the task but I am not able to set the properties of task like -

       

      1. Task document information

      2. Task Triggers

       

      I am using the following code -

       

                      documentTask.General = new DocumentTask.TaskGeneral();

                      documentTask.General.Enabled = true;

                      documentTask.General.TaskName = "Task123";

                      documentTask.General.TaskDescription = "Creating a task via QMS API";

       

                      documentTask.DocumentInfo = new DocumentTask.TaskDocumentInfo();

                      documentTask.DocumentInfo.Category = "Parallel_Test";

                      documentTask.DocumentInfo.Description = "Task created using QMS API";

       

                      Guid triggerID = new Guid("e95ecd5a-683d-1d33-26bf-66e94ff08223");

                     

                      Trigger t = new Trigger();

                      List<Trigger> List_Trigger = new List<Trigger>();

                      t.Type = TaskTriggerType.OnceTrigger;

                      t.Enabled = true;

                      t.ID = triggerID;

                      List_Trigger.Add(t);

       

                      documentTask.Triggering = new DocumentTask.TaskTriggering();

                      documentTask.Triggering.Triggers = List_Trigger;

                                                                  

                      documentTask.Scope = DocumentTaskScope.General;

                      apiClient.SaveDocumentTask(documentTask);

       

      After executing this code, I am able to see the Task123 in QEMC, but it has no triggers and no document information.

       

      Has anyone faced this issue ? Please tell me if I am missing something in this code. 

       

      Thanks,

      Samir Prasadi

        • Re: QMS API to create task
          Kristian Schmidt

          Setting up the triggers correctly is a bit tricky. Different trigger types expect different properties to be set.

          I see you haven't specified when the trigger should execute for instance.

           

          Here is an example of a recurring trigger:

           

          if (task.Triggering.Triggers == null)

                      {

                          task.Triggering.Triggers = new List<Trigger>(1);

                      }

                      var trigger = new RecurrenceTrigger { Enabled = true, ID = Guid.NewGuid()};

           

          trigger.Type = TaskTriggerType.HourlyTrigger;

                              trigger.Hourly = new RecurrenceTrigger.RecurrenceTriggerHourly

                                                   {

                                                       // RecurEvery is minutes when taskTriggerType is hourly...

                                                       RecurEvery = repeatEvery.Interval * 60,

                                                       DayOfWeekConstraints = new List<DayOfWeek>

                                                                                  {

                                                                                      DayOfWeek.Monday,

                                                                                      DayOfWeek.Tuesday,

                                                                                      DayOfWeek.Wednesday,

                                                                                      DayOfWeek.Thursday,

                                                                                      DayOfWeek.Friday,

                                                                                      DayOfWeek.Saturday,

                                                                                      DayOfWeek.Sunday

                                                                                  }

                                                   };

          task.Triggering.Triggers.Add(trigger);