GetTrackingInformation


Description

This method retrieves the tracking information for a document in the specified workflow for a company.

Parameters

Parameter

Type

Description

key

BusinessObjectKey

The business object key that specifies the document in Microsoft Dynamics GP for which workflow tracking information will be returned.

associationKey

WorkflowAssociationKey

The workflow association key that specifies the workflow being examined.


Return Value:

Value

Type

Description

GetTrackingInformationResult

Tracking

A list of workflow tracking information for the document.


Examples

The following C# example retrieves the workflow tracking information for the Sales Quote document with the document number “QTEST1032” that is part of the Dynamics GP Sales Quote Approval Workflow set up for the sample company. The tracking information is displayed in a dialog. This is the same information displayed in the Workflow History Tracking Tree window in Microsoft Dynamics GP.

Be sure to use the URL and port for your workflow server.


using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using Microsoft.Dynamics.Workflow.Proxy;

namespace WorkflowWebServiceSample
{
	class Program
	{
		static void Main(string[] args)
		{
			CompanyKey companyKey;
			WorkflowAssociationKey workflowKey;
			BusinessObjectKey key;
			KeyPart[] keyParts;
			KeyPartOfString docNumber;
			KeyPartOfString docType;
			Tracking[] trackingInfo;
			TrackingStep[] trackingSteps;
			TrackingApprover[] trackingApprovers;

			// Create an instance of the web service
			DynamicsWorkflow wsWorkflow = new DynamicsWorkflow();

			// Specify the URL used to access the Workflow web service
			wsWorkflow.Url = "http://WorkflowServer:10072/_vti_bin/WorkflowService.asmx";

			// Be sure that default credentials are being used
			wsWorkflow.UseDefaultCredentials = true;

			// Create the company key for the sample company
			companyKey = new CompanyKey();
			companyKey.Id = (-1);

			// Get the tracking information for a workflow
			workflowKey = new WorkflowAssociationKey();
			workflowKey.OrganizationKey = companyKey;
			workflowKey.WorkflowName = "Dynamics GP Sales Quote Approval Workflow";

			// Specify which SOP Quote document
			key = new BusinessObjectKey();

			// Build the key parts
			// Document number
			docNumber = new KeyPartOfString();
			docNumber.Name = "SOPNUMBE";
			docNumber.PartValue = "QTEST1032";

			// Document type
			docType = new KeyPartOfString();
			docType.Name = "SOPTYPE";
			docType.PartValue = "Quote";

			// Assemble the key parts
			keyParts = new KeyPart[2];
			keyParts[0] = docNumber;
			keyParts[1] = docType;

			// Add the key parts to the key
			key.KeyParts = keyParts;

			// Get the tracking information for this workflow and document
			trackingInfo = wsWorkflow.GetTrackingInformation(key, workflowKey);

			// Display the tracking information
			StringBuilder trackingList = new StringBuilder();
			foreach (Tracking t in trackingInfo)
			{
				trackingList.AppendLine("Status: " + t.WorkflowApprovalStatus);
				trackingList.AppendLine("Originator: " + t.Originator);

				// Look at the steps
				trackingSteps = t.Steps;
				foreach (TrackingStep ts in trackingSteps)
				{
					trackingList.AppendLine(ts.StepName);

					// Look at the approvers for the step
					trackingApprovers = ts.Approvers;
					foreach (TrackingApprover ta in trackingApprovers)
					{
						trackingList.AppendLine("	 " + ta.Approver);
				}
			}
		}
			MessageBox.Show(trackingList.ToString());
	}
}
}


Documentation Feedback