This method disables the workflow for a specific document.







The workflow in which the document is located.



Specifies the document for which workflow will be disabled.


The following C# example disables the workflow for the Sales Quote document with the document number “QTEST1035” that is part of the Dynamics GP Sales Quote Approval Workflow set up for the sample company.

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;

			// 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);

			// Specify the workflow
			workflowKey = new WorkflowAssociationKey();
			workflowKey.OrganizationKey = companyKey;
			workflowKey.WorkflowName = "Dynamics GP Sales Quote Approval Workflow ";

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

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

			// 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;

			// Disable the workflow for the specified document
			wsWorkflow.DisableRunningWorkflow(workflowKey, key);

Documentation Feedback