Share via


CRMCustomization.Transform Method

The Transform method generates the target object XML data from the source object.

Syntax

[Visual Basic .NET]
Public Function Transform(
  ByVal Caller As CUserAuth,
  ByVal SourceObject As CObjectName,
  ByVal TargetObjectType As Integer,
  ByVal TargetFieldType As Integer
) As String
[C#]
public string Transform(
  CUserAuth  Caller,
  CObjectName  SourceObject,
  int  TargetObjectType,
  int  TargetFieldType
);
[C++]
public: String* Transform(
  CUserAuth*  Caller,
  CObjectName*  SourceObject,
  long  TargetObjectType,
  long  TargetFieldType
);

Parameters

Caller

Specifies the identity of the caller. To perform this action, the caller must have the prvReadCustomization privilege. See CUserAuth.

SourceObject

Specifies the source object from which target object is to be generated. See CObjectName.

TargetObjectType

Specifies the type of the target object. See ObjectType.

TargetFieldType

Specifies the type of fields in the target object XML string: all fields, only the fields valid for create, read or update. See TRANSFORM_TARGET_FIELD_TYPE Class

Return Value

Returns a String type that specifies the XML data that is generated for the target object.

Remarks

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#]
// strServerName should be set with the name of the platform Web server
String strServerName = "myservername";

// strVirtualDirectory should be set with the name of the Microsoft CRM
// virtual directory on the platform Web server
String strVirtualDirectory = "mscrmservices";
String strDir = String.Concat("https://", strServerName, "/",
                              strVirtualDirectory, "/");

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

// CRMCustomization proxy object
Microsoft.Crm.Platform.Proxy.CRMCustomization customization
                    = new Microsoft.Crm.Platform.Proxy.CRMCustomization();
customization.Credentials = System.Net.CredentialCache.DefaultCredentials;
customization.Url = String.Concat(strDir, "CRMCustomization.srf");

String strErrorMsg;
String strOpportunityId = "{64A1C978-4A67-4845-B481-F4A81F67B5E0}";

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

   // Initialize the opportunity object
   Microsoft.Crm.Platform.Proxy.CObjectName objName
                       = new Microsoft.Crm.Platform.Proxy.CObjectName();
   objName.Id = strOpportunityId;
   objName.Type = Microsoft.Crm.Platform.Proxy.ObjectType.otOpportunity;

   // Convert an opportunity to a quote
   String strResultsXml = customization.Transform (userAuth, objName,
               Microsoft.Crm.Platform.Types.ObjectType.otQuote,
               Microsoft.Crm.Platform.Types.TRANSFORM_TARGET_FIELD_TYPE.TFT_VALID_FOR_CREATE);
}
catch (System.Web.Services.Protocols.SoapException err)
{
   // Process the platform error here
   strErrorMsg = String.Concat("ErrorMessage: ", err.Message, " ",
                        err.Detail.OuterXml, " Source: ", err.Source);
}

Requirements

Namespace: Microsoft.Crm.Platform.Proxy

Assembly: Microsoft.Crm.Platform.Proxy.dll

See Also

© 2005 Microsoft Corporation. All rights reserved.