Sunday, June 3, 2012

How to perform task Search based on process instance id using script ?

This Snippet of code will help in performing the task search using process instance id in lombardi.

var procName = new TWSearchCondition();
        procName.column = new TWSearchColumn();
        procName.column.type = TWSearchColumn.Types.ProcessInstance;
        procName.column.name = TWSearchColumn.ProcessInstanceColumns.ID;
        procName.operator = TWSearchCondition.Operations.Equals;
        procName.value = tw.local.processInstanceId;       


       
        var stRcvd = new TWSearchCondition();
        stRcvd.column = new TWSearchColumn();
        stRcvd.column.type = TWSearchColumn.Types.Task;
        stRcvd.column.name = TWSearchColumn.TaskColumns.Status;
        stRcvd.operator = TWSearchCondition.Operations.Equals;
        stRcvd.value = TWTask.Statuses.Received;              

        var search = new TWSearch();
       
        search.conditions =  new Array (procName, stRcvd);
        search.organizedBy = TWSearch.OrganizeByTypes.Task;
       
        var tasksFound = search.executeForTasks();

variable task found will contain the task with details for the process instance id (tw.local.processInstanceId) which are in received status.



No comments:

Post a Comment