Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Select fields and values in task reduce category using QlikView Management API (QMSAPI)

Hi I am trying to select/add task reduce fields and values with the QlikView Management API. I've been able to successfully create a task with the API so far, and I have been able to interact with the text fields and options in the other categories, but I am stuck on this. Here is a picture representing what I want to do with the .NET program I wrote using the API.

QMSAPIFieldSelect.PNG

Here is the code I have so far for JUST the reduce category, I could give more code but the entire program is a couple hundred lines long so it would be a little extensive.

docTask.Reduce = new DocumentTask.TaskReduce();

docTask.Reduce.Static = new TaskReduceStatic();
List<TaskReduction> TaskReductionList = new List<TaskReduction>();
docTask.Reduce.Static.Reductions = TaskReductionList.ToArray();
docTask.Reduce.Dynamic = new TaskReduceDynamic();
docTask.Reduce.Dynamic.Type = TaskReductionType.ByField;
docTask.Reduce.Dynamic.FieldName = "Config.ActiveDataSource";
docTask.Reduce.DocumentNameTemplate = "%SourceDocumentName% %ScriptParameter%";

Does anyone know how to do this?

(By the way my program is written in C#)

1 Solution

Accepted Solutions
Not applicable
Author

I seem to have solved my problem, I found the tools I needed in the document .Reduce.Static object.

Here is the updated code

docTask.Reduce.Static = new TaskReduceStatic();

            List<TaskReduction> TaskReductionList = new List<TaskReduction>();

            TaskReduction tr = new TaskReduction();

            TaskReduction.TaskReductionField trf = new TaskReduction.TaskReductionField();

            tr.Type = TaskReductionType.ByField;

            trf.Name = "Variable.Sort";

            trf.Value = "530";

            tr.Field = trf;

            TaskReductionList.Add(tr);

            docTask.Reduce.Static.Reductions = TaskReductionList.ToArray();

I was unaware that you were required to make a taskreduction object, then a taskreductionfield object to put inside of that. Also it was not working until I specified the type as ByField. (tr.Type = TaskReductionType.ByField;)

View solution in original post

1 Reply
Not applicable
Author

I seem to have solved my problem, I found the tools I needed in the document .Reduce.Static object.

Here is the updated code

docTask.Reduce.Static = new TaskReduceStatic();

            List<TaskReduction> TaskReductionList = new List<TaskReduction>();

            TaskReduction tr = new TaskReduction();

            TaskReduction.TaskReductionField trf = new TaskReduction.TaskReductionField();

            tr.Type = TaskReductionType.ByField;

            trf.Name = "Variable.Sort";

            trf.Value = "530";

            tr.Field = trf;

            TaskReductionList.Add(tr);

            docTask.Reduce.Static.Reductions = TaskReductionList.ToArray();

I was unaware that you were required to make a taskreduction object, then a taskreductionfield object to put inside of that. Also it was not working until I specified the type as ByField. (tr.Type = TaskReductionType.ByField;)