This is part four of my series of posts on the GlobalSight Web Services API. See below for the previous posts:
- Interacting with the GlobalSight Web Services API from C#
- GlobalSight Web Services API: Automate Translation Memory Upload
- GlobalSight Web Services API: Job Creation
Here, I’d like to cover how you can manipulate workflows in GlobalSight via the API. For example, dispatching a workflow, accepting tasks in a workflow, or completing or moving workflows on to the next step.
This can be useful if you want to automate specific steps, or if you want to use an interface other than GlobalSight when dealing with workflows.
There are a couple of relevant functions that are pre-requisites when dealing with workflows programmatically:
- getJobAndWorkflowInfo – This returns details about workflows in a particular job. The ID of the job in question is passed as a parameter to this function. This will return an XML response, detailing as well as the workflow information, some basic information about the job. We need this to get the ID of the workflow which we want to work with, within a particular job.
- getAcceptedTasksInWorkflow – This will return the task information for a workflow, given the workflow ID (which we would have got from getJobAndWorkflowInfo). With the XML response here, we’ll be able to search for specific tasks in a workflow, and get the task ID – this is what is required in order to manipulate specific tasks in a workflow.
From the above, (I leave the parsing of the XML response as an exercise to the reader), we can begin to perform workflow tasks by using the task ID.
// Accept task string acceptTask = client.acceptTask(auth, "63781"); Console.WriteLine("Accept Task Response: " + acceptTask); // Send this worfklow to the 'Write to TM' step string completeTask = client.completeTask(auth, "63781", "Write to TM"); Console.WriteLine("\n\nComplete Task Response: " + completeTask);
The above is a very simple example of accepting a particular task in a workflow (using the workflow ID), and sending it to the next step in the workflow via ‘Write to TM’.
‘Write to TM‘ here is the actual text on the arrow in the workflow diagram. I found this syntax strange, but it seems to work.
It should be noted that the user under which you are logged into the web service with must be on the list of those allowed to accept the task you are trying to accept, you will receive an error otherwise.
The GlobalSight Web Services API documentation has much more information the the types of actions you can perform on workflows, but the above should get you started.