Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I can't seem to be able to set the name on the new task, task gets created with default name.
Here's my code, any ideas are welcome.
Dim QMSClient As New QMSBackendClient()
Dim QvsId As Guid
'Gets the request Key when the page is loaded
ServiceKeyClientMessageInspector.ServiceKey = QMSClient.GetTimeLimitedServiceKey()
'Fetching the ID of the first QVS resource
Dim qvsServices As QVPublisher.QMSBackendService.ServiceInfo()
qvsServices = QMSClient.GetServices(ServiceTypes.QlikViewDistributionService)
QvsId = New Guid(qvsServices(0).ID.ToString())
Dim qvDocs As QVPublisher.QMSBackendService.DocumentNode()
qvDocs = QMSClient.GetSourceDocuments(QvsId)
Dim qvDocTasks As New QVPublisher.QMSBackendService.DocumentTask
qvDocTasks.QDSID = QvsId
qvDocTasks.Document = qvDocs(1)
qvDocTasks.DocumentInfo = New QVPublisher.QMSBackendService.DocumentTask.TaskDocumentInfo
qvDocTasks.Distribute = New QVPublisher.QMSBackendService.DocumentTask.TaskDistribute
qvDocTasks.Reduce = New QVPublisher.QMSBackendService.DocumentTask.TaskReduce
qvDocTasks.Reload = New QVPublisher.QMSBackendService.DocumentTask.TaskReload
qvDocTasks.General = New QVPublisher.QMSBackendService.DocumentTask.TaskGeneral
qvDocTasks.General.TaskName = "API TEST"
qvDocTasks.General.Enabled = False
qvDocTasks.Triggering = New QVPublisher.QMSBackendService.DocumentTask.TaskTriggering
QMSClient.SaveDocumentTask(qvDocTasks)
Hi,
You might want to try the following:
Set the property 'Scope' on the object DocumentTask. You can set the scope using DocumentTaskScope.
For example: if you want to set values on the general-tab and reload-tab of a task use:
C# example
documentTask.Scope = DocumentTaskScope.General | DocumentTaskScope.Reload;
Example code for creating a task in C#:
QMSBackendClient qmsClient = new QMSBackendClient();
DocumentTask documentTask = new DocumentTask();
//Set time limited service key
ServiceKeyClientMessageInspector.ServiceKey = qmsClient.GetTimeLimitedServiceKey();
//Get QDS guid
List<ServiceInfo> serviceList = qmsClient.GetServices(ServiceTypes.QlikViewDistributionService);
Guid qdsGuid = serviceList[0].ID;
//Get source documents
List<DocumentNode> sourceDocuments = qmsClient.GetSourceDocuments(qdsGuid);
documentTask.QDSID = qdsGuid;
documentTask.Document = sourceDocuments[0]; //Get first source document for this example
documentTask.General = new DocumentTask.TaskGeneral();
documentTask.General.Enabled = true;
documentTask.General.TaskName = "Task1";
documentTask.General.TaskDescription = "Creating a task via QMS API";
documentTask.Scope = DocumentTaskScope.General;
//Create task
qmsClient.SaveDocumentTask(documentTask);
I was able to succesfully create a task with the specified task name uing the scope property.
A default task name is set when I do not use the scope property.
Hope this helps!
Im seeing the same thing.
I have noticed that if i set a GUID for the task then the task name is set as "Default" but if i leave the guid out then the task name is set as "reload of \\pathtodoc\app.qvw"
So it seems that there might be an extra setting to apply to get it to ignore these defaults.
Hi,
Just to follow up. If you create an empty task, you can then grab the task using the API and you can then correctly apply all of the settings. Not only does this apply to Names and Catergories but it also applies to triggers and other settings too.
I have raise it as an issue for the R&D folks to look at.
Joe
Thanks Joe.
Hi,
You might want to try the following:
Set the property 'Scope' on the object DocumentTask. You can set the scope using DocumentTaskScope.
For example: if you want to set values on the general-tab and reload-tab of a task use:
C# example
documentTask.Scope = DocumentTaskScope.General | DocumentTaskScope.Reload;
Example code for creating a task in C#:
QMSBackendClient qmsClient = new QMSBackendClient();
DocumentTask documentTask = new DocumentTask();
//Set time limited service key
ServiceKeyClientMessageInspector.ServiceKey = qmsClient.GetTimeLimitedServiceKey();
//Get QDS guid
List<ServiceInfo> serviceList = qmsClient.GetServices(ServiceTypes.QlikViewDistributionService);
Guid qdsGuid = serviceList[0].ID;
//Get source documents
List<DocumentNode> sourceDocuments = qmsClient.GetSourceDocuments(qdsGuid);
documentTask.QDSID = qdsGuid;
documentTask.Document = sourceDocuments[0]; //Get first source document for this example
documentTask.General = new DocumentTask.TaskGeneral();
documentTask.General.Enabled = true;
documentTask.General.TaskName = "Task1";
documentTask.General.TaskDescription = "Creating a task via QMS API";
documentTask.Scope = DocumentTaskScope.General;
//Create task
qmsClient.SaveDocumentTask(documentTask);
I was able to succesfully create a task with the specified task name uing the scope property.
A default task name is set when I do not use the scope property.
Hope this helps!
Awesome, right on the money.
Thanks Bas.
Not go to test this just yet but im pretty sure you are right based on another conversation.
There are a few oddities with other areas the API requiring you to set some values you dont expect for it to work as expected.
Im going to see if i can start a blog to push out some samples that will hopefully show up on google searches!
Hi,
In your example did you try to add the triggers, document info using QMS API ? If yes can you tell me how did you do it ?
I have written following code but it is not working -
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.
Regards,
Samir Prasadi
Prasadi - do you only have QlikView Server in your case and NOT publisher?
Im trying to resolve a similar issue where the code works fine if i have publisher licensed but if i dont then it creates the task without any triggers.
You have set the document scope to:
documentTask.Scope = DocumentTaskScope.General;
QMS API will only look for the DocumentTask.TaskGeneral object because you have defined this in the scope property.
Try to change the document task scope line to this:
documentTask.Scope = DocumentTaskScope.General | DocumentTaskScope.DocumentInfo | DocumentTaskScope.Triggering;
This should work.