Share via


CRMRichClientSync.PrepareSync Method

The PrepareSync method prepares an offline synchronization operation. This method creates a list of objects that a specific user can see (which correspond to the user's privileges) and that is downloaded later in the synchronization cycle.

Syntax

[Visual Basic .NET]
Public Function PrepareSync(
  ByVal Caller As CUserAuth,
  ByVal SubscriptionId As String,
  ByVal IncludeAttachments As Integer,
  ByVal SyncBusinessUnitOnly As Integer,
  ByVal MaxSalesLiteratureSize As UInt32,
  ByVal SalesLiteratureItems As String,
  ByVal LastSync As String,
  ByRef UserInfo As Byte()
) As String
[C#]
public string PrepareSync(
  CUserAuth  Caller,
  string  SubscriptionId,
  int  IncludeAttachments,
  int  SyncBusinessUnitOnly,
  uint  MaxSalesLiteratureSize,
  string  SalesLiteratureItems,
  string  LastSync,
  out byte[]  UserInfo
);
[C++]
public: String* PrepareSync(
  CUserAuth*  Caller,
  String*  SubscriptionId,
  long  IncludeAttachments,
  long  SyncBusinessUnitOnly,
  unsigned long  MaxSalesLiteratureSize,
  String*  SalesLiteratureItems,
  String*  LastSync,
  unsigned char*  UserInfo
);

Parameters

Caller

Specifies the identity of the caller. To perform this action, the caller must have the prvReadOrganization, prvReadBusinessUnit, prvReadUser, prvReadUserSettings, prvReadTeam, prvReadRole, and prvReadLicense privileges. See CUserAuth.

SubscriptionId

Specifies the ID of the subscription.

IncludeAttachments

Specifies whether to include attachments when performing the synchronization.

SyncBusinessUnitOnly

Specifies whether to synchronize only the business unit.

MaxSalesLiteratureSize

Specifies the maximum size of the sales literature items that are to be synchronized.

SalesLiteratureItems

Specifies sales literature items.

LastSync

Specifies the time of the last synchronization.

UserInfo

[out] Specifies the user security credentials. The Outlook client stores this binary data in the database, which is then used by offline security for access checks.

Return Value

Returns a String type that specifies the returned time of this synchronization.

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#]
// 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";

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

string strErrorMsg;
string strSubscriptionId = "{57ELDC97-KL8E-3371-9022-7DKCFBD0F0E3}";
string strSalesLiteratureItemIds = "{CD079251-CD0E-4154-B0D6-8062D2C98C1D},{0961553A-D5DD-462E-AB11-C3750DC1A9F9}";
string strDate = DateTime.Now.AddDays(-5).ToString("s");

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

   byte[] uInfo;

   // Prepare the synchronization process
   richclientsync.PrepareSync(userAuth, strSubscriptionId, 1, 1, 16384, strSalesLiteratureItemIds, strDate, out uInfo);
}
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.