CrmCalloutBase.PreSetState Method

banner art

Specifies a method called before a set state operation.

Syntax

[Visual Basic .NET]
Overridable Public Function PreSetState(
  ByVal userContext As CalloutUserContext,
  ByVal entityContext As CalloutEntityContext,
  ByRef newStateCode As Integer,
  ByRef newStatusCode As Integer,
  ByRef errorMessage As String
) As PreCalloutReturnValue
[C#]
public virtual PreCalloutReturnValue PreSetState(
  CalloutUserContext  userContext,
  CalloutEntityContext  entityContext,
  ref int  newStateCode,
  ref int  newStatusCode,
  ref string  errorMessage
);
[JScript]
public virtual function PreSetState(
  userContext : CalloutUserContext,
  entityContext : CalloutEntityContext,
  newStateCode : int,
  newStatusCode : int,
  errorMessage : String
) : PreCalloutReturnValue;

Parameters

userContext

Contains information about the user who is performing the set state operation. See CalloutUserContext.

entityContext

Contains information about the entity on which the set state operation is being performed. See CalloutEntityContext.

newStateCode

[ref] The new state code for the entity.

newStatusCode

[ref] The new status code for the entity.

errorMessage

[ref] A string that contains the error message to be returned to the application. The error message string should not exceed 1,500 characters in length.

Return Value

Returns a PreCalloutReturnValue type that specifies what action to take after this method completes.

Example

The following code example shows how to log an object state set using a pre-callout.

public override PreCalloutReturnValue PreSetState(CalloutUserContext userContext,
                       CalloutEntityContext entityContext,
                       ref int newStateCode,
                       ref int newStatusCode,
                       ref string errorMessage)
{
   TextWriter log = TextWriter.Synchronized(
     File.AppendText(@"C:\CRM_SDK_Drop\SetState.txt"));
   log.WriteLine("PreSetState");
   log.WriteLine("ObjectType: " +
     entityContext.EntityTypeCode.ToString());
   log.WriteLine("ObjectId: " + entityContext.InstanceId.ToString());
   log.WriteLine("CreatorId: " + userContext.UserId.ToString());
   log.WriteLine();
   log.Close();

   return PreCalloutReturnValue.Continue;
}

Requirements

Namespace: Microsoft.Crm.Callout

Assembly: microsoft.crm.platform.callout.base.dll

See Also

© 2007 Microsoft Corporation. All rights reserved.