Share via


CRMRichClientSync.CreateSubscription Method

The CreateSubscription method creates a subscription. A subscription allows a user on a specific computer to go offline by using the Microsoft CRM Sales for Outlook client.

Syntax

[Visual Basic .NET]
Public Function CreateSubscription(
  ByVal Caller As CUserAuth,
  ByVal UserId As String,
  ByVal MachineName As String
) As String
[C#]
public string CreateSubscription(
  CUserAuth  Caller,
  string  UserId,
  string  MachineName
);
[C++]
public: String* CreateSubscription(
  CUserAuth*  Caller,
  String*  UserId,
  String*  MachineName
);

Parameters

Caller

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

UserId

Specifies the ID of the user.

MachineName

Specifies the name of the Outlook client computer.

Return Value

Returns a String type that specifies the ID of the new subscription.

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.Proxy.BizUser bizUser = new Microsoft.CRM.Proxy.BizUser ();
bizUser.Credentials = System.Net.CredentialCache.DefaultCredentials;
bizUser.Url = strDir + "BizUser.srf";

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

string strErrorMsg;
string UserId = "{34EAEC97-AK8E-6671-9022-7DKCFBD0F0E3}";
string strMName = "localmachine";

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

   // Create a subscription
   string strSubscriptionId = richclientsync.CreateSubscription(userAuth, UserId, strMName);

}
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.Proxy

Assembly: microsoft.crm.proxy.dll

See Also

© 2003 Microsoft Corporation. All rights reserved.