CRMProcess.Activate Method

The Activate method activates a workflow process, which means it compiles and copies (clones) the process so that the process can be executed. It also sets the process statecode to WFPS_ACTIVE. See Remarks.

Syntax

[Visual Basic .NET]
Public Function Activate(
  ByVal Caller As CUserAuth,
  ByVal ProcessId As String,
  ByRef ErrInfo As CWorkflowErrorInfo()
) As Integer
[C#]
public int Activate(
  CUserAuth  Caller,
  string  ProcessId,
  out CWorkflowErrorInfo[]  ErrInfo
);
[C++]
public: long Activate(
  CUserAuth*  Caller,
  String*  ProcessId,
  CWorkflowErrorInfo**  ErrInfo
);

Parameters

Caller

Specifies the identity of the caller. To perform this action, the caller must have the prvWriteWorkflowProcess privilege and access rights on the object to be activated. See CUserAuth.

ProcessId

Specifies the ID of the process to be activated.

ErrInfo

[out]  Specifies an array of error information structures. Any compile errors during process activation are reported in this structure. See CWorkflowErrorInfo.

Return Value

Returns an Int32 type that specifies the flag indicating either success (non-zero) or failure (zero). If the call fails, the errInfo structure contains the reason for the failure.

Remarks

For this method to succeed, the specified process must not yet have been activated. After the process is activated, a copy (clone) of the process is created; And it is this copy on which the process instances run. This makes it possible to modify or delete the original process without affecting the process instances. Because of this implementation, the GUIDs that are returned from CRMProcessController APIs and that are listed in errors in the System Event Log refer to GUIDs from the copied process.

If there is an error, SOAP throws an exception and the error message is reported in System.Web.Services.Protocols.SoapException.Detail.OuterXml.

All IDs passed to the platform are GUIDs wrapped in braces. For example: {6522D89A-A752-4455-A2B0-51494C6957C3}

Example

[C#]
// strServer should be set with the name of the platform Web server
string strServer = "myservername";

// virtualDirectory should be set with the name of the Microsoft CRM
// virtual directory on the platform Web server
string virtualDirectory = "mscrmservices";
string strDir = "https://" + strServer + "/" + virtualDirectory + "/";

// BizUser proxy object
Microsoft.Crm.Platform.Proxy.BizUser bizUser = new Microsoft.Crm.Platform.Proxy.BizUser ();
bizUser.Credentials = System.Net.CredentialCache.DefaultCredentials;
bizUser.Url = strDir + "BizUser.srf";

// CRMProcess proxy object
Microsoft.Crm.Platform.Proxy.CRMProcess  process = new Microsoft.Crm.Platform.Proxy.CRMProcess();
process.Credentials = System.Net.CredentialCache.DefaultCredentials;
process.Url = strDir + "CRMProcess.srf";

string strErrorMsg;
try
{
   Microsoft.Crm.Platform.Proxy.CUserAuth userAuth = bizUser.WhoAmI();

   string strProcessId = "{93639AD8-CA01-4B16-B09C-EFEE53FA8799}";

   Microsoft.Crm.Platform.Proxy.CWorkflowErrorInfo[] errinfo = new Microsoft.Crm.Platform.Proxy.CWorkflowErrorInfo[]{};

   // Activate the process
   int error = process.Activate(userAuth, strProcessId, out errinfo);
}
catch (System.Web.Services.Protocols.SoapException err)
{
   // Process the platform error here
   strErrorMsg = ("ErrorMessage: " + err.Message + " " + err.Detail.OuterXml + " Source: " + err.Source );
}
catch (Exception err)
{
   // Process other errors here
   strErrorMsg = ("ErrorMessage: " + err.Message );
}

Requirements

Namespace: Microsoft.Crm.Platform.Proxy

Assembly: Microsoft.Crm.Platform.Proxy.dll

See Also

© 2005 Microsoft Corporation. All rights reserved.