Qlik Community

QlikView Publisher

Discussion Board for collaboration on QlikView Publisher.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

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

1 Solution

Accepted Solutions
Not applicable

Re: QMS API to create task

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);

4 Replies
Not applicable

Re: QMS API to create task

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);

Not applicable

Re: QMS API to create task

Hi,

Thank you for the reply. I forgot to update this thread, I was able to set the required properties of task by setting the scope property.

Regards,

Samir.

Not applicable

Re: QMS API to create task

Glad to hear it.

You should mark the thread as answered, so it might help others.

Regards

Kristian

Not applicable

Re: QMS API to create task

May I know what is repeatEvery here please.

Community Browser