Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Create On Multiple Events Completed trigger using QMS API

Hi All,

We are trying to create all the different triggers that is possible to create with QMC and reaply it using the QMS API. We are able to create all triggers possibles like Once Trigger, Hourly Trigger... but we have problems with On Multiple Events Completed trigger. We are using MultipleEventTrigger method and filling all the information and the task is created but when we check on the QMC the Task completed dependencies is empty. It seems that the step of providing the task dependencies we do something wrong. Can someone help with that issue on provide some example?

Our code:


MultipleEventTrigger st = new MultipleEventTrigger();
st.ID = triggerID;
st.Type = TaskTriggerType.AndTrigger;
List<Trigger> trigger = new List<Trigger>();
st.TimeConstraint = 360;
st.Enabled = true;
st.SubTriggers = new List<Trigger>                       

Many thanks

2 Replies
New Contributor III

Re: Create On Multiple Events Completed trigger using QMS API

Hi Juame,

Here are some steps to create a document task with a multiple event trigger. I hope this gets you started.

  1. Create a DocumentTask object (with at least scope general and triggering for this example).

  2. Create a DocumentTask.TaskTriggering object and assign it to the Triggering property of the DocumentTask object.

    DocumentTask.TaskTriggering taskTriggering  = new DocumentTask.TaskTriggering();

    taskTriggering.ExecutionAttempts            = 1;

    taskTriggering.ExecutionTimeout             = (uint)executionTimeout;

    taskTriggering.TaskDependencies             = new List<TaskInfo>();

    taskTriggering.Triggers                     = new List<Trigger>();


  3. Create a MultipleEventTrigger object and add this to the taskTriggering.Triggers list.

    MultipleEventTrigger eventTrigger = null;

    eventTrigger                = new MultipleEventTrigger();

    eventTrigger.Enabled        = true;

    eventTrigger.ID             = Guid.NewGuid(); //Make sure to set a GUID

    eventTrigger.Type           = TaskTriggerType.AndTrigger;

    eventTrigger.TimeConstraint = 360;

    eventTrigger.SubTriggers    = new List<Trigger>();


    eventTrigger.SubTriggers.Add(GetTaskEventTrigger("Movies Database.qvw"));

  4. Add a TaskEventTrigger to the SubTriggers list of the MultipleEventTrigger object.

    Set the correct TaskID by fetching the ID of an existing task using a DocumentTask or TaskInfo object.

    TaskEventTrigger taskEventTrigger = null;

    taskEventTrigger            = new TaskEventTrigger();

    taskEventTrigger.Enabled    = true;

    taskEventTrigger.ID         = Guid.NewGuid(); //Make sure to set a GUID

    taskEventTrigger.TaskID     = documentTask.ID; //TaskID of the dependent task

    taskEventTrigger.Type       = TaskTriggerType.TaskFinishedTrigger;

  5. Make sure to set all the necessary properties of the DocumentTask object and save it using the method SaveDocumentTask.

Make sure to set a GUID on the triggers, otherwise you will have a TaskFinishedTrigger and an empty AndTrigger (no task completed dependencies) instead of one AndTrigger with task completed dependencies.

Good luck!

Bas Knol

The Implementation Group

Not applicable

Re: Create On Multiple Events Completed trigger using QMS API

Many thanks Bas. Is working as you said, your comments are really helpfull!

Community Browser