CrmServiceClient Class

Definition

Primary implementation of the API interface for CRM.

public ref class CrmServiceClient sealed : IDisposable, Microsoft::Xrm::Sdk::IOrganizationService
public class CrmServiceClient : IDisposable, Microsoft.Xrm.Sdk.IOrganizationService
type CrmServiceClient = class
    interface IOrganizationService
    interface IDisposable
Public Class CrmServiceClient
Implements IDisposable, IOrganizationService
Inheritance
CrmServiceClient
Implements

Constructors

CrmServiceClient(NetworkCredential, AuthenticationType, String, String, String, Boolean, Boolean, OrganizationDetail)

Logs in with User Supplied Settings using AD or IFD

CrmServiceClient(NetworkCredential, String, String, String, Boolean, Boolean, OrganizationDetail)

Logs in with User Supplied Settings using AD

CrmServiceClient(OrganizationServiceProxy)

Uses the Organization service proxy provided by the user.

CrmServiceClient(OrganizationWebProxyClient)

Uses the Organization Web proxy Client provided by the user

CrmServiceClient(String)

CrmServiceClient to accept the connectionstring as a parameter.

CrmServiceClient(String, SecureString, String, String, Boolean, Boolean, OrganizationDetail, Boolean)

Logs in with User Supplied Settings using Windows Live or Office 365

CrmServiceClient(String, SecureString, String, String, Boolean, OrganizationDetail, UserIdentifier, String, Uri, String, OrganizationWebProxyClient, PromptBehavior, Boolean)

Log in with OAuth for online connections.

CrmServiceClient(String, SecureString, String, String, String, String, String, Boolean, Boolean, OrganizationDetail)

Logs in with Claims based User ID

CrmServiceClient(String, SecureString, String, String, String, String, String, Boolean, Boolean, OrganizationDetail, UserIdentifier, String, Uri, String, OrganizationWebProxyClient, PromptBehavior)

Log in with OAuth for On-Premises connections.

CrmServiceClient(Uri, Boolean)

Offloads Authentication to class that implements IOverrideAuthHookWrapper.

CrmServiceClient(Uri, String, SecureString, Boolean, String)

ClientID \ ClientSecret Based Authentication flow, allowing for Secure Client ID passing.

CrmServiceClient(Uri, String, String, Boolean, String)

ClientID \ ClientSecret Based Authentication flow.

CrmServiceClient(X509Certificate2, StoreName, String, Uri, Boolean, OrganizationDetail, String, Uri, String)

Log in with Certificate Auth OnLine connections. This requires the org API URI.

CrmServiceClient(X509Certificate2, StoreName, String, Uri, String, Boolean, Boolean, OrganizationDetail, String, Uri, String)

Log in with Certificate Auth On-Premises connections.

Fields

_sdkVersionProperty

SDK Version property backer.

Properties

ActiveAuthenticationType

Authentication Type to use

AddHttpRequestHeaders

External override to allow for users to add additional headers to the outbound request to dataverse. This will be called for each outbound request used to dataverse.

Authority

OAuth Authority.

AuthOverrideHook

External token acquire behavior, Internal use only.

BypassPluginExecution

False by default. When true, Adds the bypass plugin behavior for requests made while this property is true.

Important: This will only apply if the caller has the prvBypassPlugins permission to bypass plugins. If its attempted without the permission requests will fault.

CallerAADObjectId

Gets or Sets the AAD Object ID of the caller. This is supported for Xrm 8.1 + only

CallerId

Gets or Sets the current caller ID

ConnectedOrgFriendlyName

Returns the friendly name of the connected org.

ConnectedOrgId

ID of the connected organization.

ConnectedOrgPublishedEndpoints

Returns the endpoint collection for the connected org.

ConnectedOrgUniqueName

Returns the unique name for the org that has been connected.

ConnectedOrgVersion

Returns the Version Number of the connected CRM organization. If access before the Organization is connected, value returned will be null or 0.0

ConnectionLockObject

This is the connection lock object that is used to control connection access for various threads. This should be used if you are using the CRM queries via Linq to lock the connection

CrmConnectOrgUriActual

Returns the Actual URI used to connect to CRM. this URI could be influenced by user defined variables.

CurrentAccessToken

Returns the current access token in Use to connect to CDS. Note: this is only available when a token based authentication process is in use.

DisableCrossThreadSafeties

Disabled internal cross thread safeties, this will gain much higher performance, however it places the requirements of thread safety on you, the developer.

EnableAffinityCookie

Defaults to True.

When true, this setting applies the default connection routing strategy to connections to Dataverse.

This will 'prefer' a given node when interacting with Dataverse which improves overall connection performance.

When set to false, each call to Dataverse will be routed to any given node supporting your organization.

See https://docs.microsoft.com/en-us/powerapps/developer/data-platform/api-limits#remove-the-affinity-cookie for proper use.

EnableDeprecatedOnLineWSTrustFlow

When set true, enables ws-trust auth flows for online

EnvironmentId

Gets the PowerPlatform Environment Id of the environment that is hosting this instance of CDS

ForceServerMetadataCacheConsistency

This will force the CDS server to refresh the current metadata cache with current DB config. Note, that this is a performance impacting property. Use of this flag will slow down operations server side as the server is required to check for consistency of the platform metadata against disk on each API call executed. It is recommended to use this ONLY in conjunction with solution import or delete operations.

InMemoryLogCollectionEnabled

Enabled Log Capture in memory This capability enables logs that would normally be sent to your configured

InMemoryLogCollectionTimeOutMinutes

This is the number of minuets that logs will be retained before being purged from memory. Default is 5 min. This capability controls how long the log cache is kept in memory.

IsBatchOperationsAvailable

if true then Batch Operations are available.

IsReady

if true the service is ready to accept requests.

LastCrmError

Returns the Last String Error that was created by the CRM Connection

LastCrmException

Returns the Last Exception from CRM.

MaxConnectionTimeout

Gets or Sets the Max Connection Timeout for the connection. Default setting is 2 min, this property can also be set via app.config/app.settings with the property MaxCrmConnectionTimeOutMinutes

MaxRetryCount

Gets or sets max retry count.

OAuthUserId

Logged in Office365 UserId using OAuth.

OrganizationDetail

OrganizationDetails for the currently connected environment.

OrganizationServiceProxy

Exposed OrganizationServiceProxy for consumers

OrganizationWebProxyClient

Exposed OrganizationWebProxyClient for consumers

RecommendedDegreesOfParallelism

Server Hint for the number of concurrent threads that would provbide optimal processing.

RetryPauseTime

Gets or sets retry pause time.

SdkVersionProperty

Get the Client SDK version property

SessionTrackingId

This ID is used to support CDS Telemtry when trouble shooting SDK based errors. When Set by the caller, all CDS API Actions executed by this client will be tracked under a single session id for later troubleshooting. For example, you are able to group all actions in a given run of your client ( seveal creates / reads and such ) under a given tracking id that is shared on all requests. providing this ID when when reporting a problem will aid in trouble shooting your issue.

TenantId

Gets the Tenant Id of the current connection.

Methods

AddEntityToQueue(Guid, String, String, Guid, Boolean, Guid)

This will route a Entity to a public queue,

AssignEntityToUser(Guid, String, Guid, Guid)

Assign an Entity to the specified user ID

Associate(String, Guid, Relationship, EntityReferenceCollection)

Issues an Associate Request to CRM.

CancelSalesOrder(Guid, Dictionary<String,CrmDataTypeWrapper>, Int32, Guid)

Cancel Sales order

Clone()

Clone, 'Clones" the current CRM Service client with a new connection to CRM. Clone only works for connections creating using OAuth Protocol.

Clone(Assembly)

Clone, 'Clones" the current CRM Service client with a new connection to CRM. Clone only works for connections creating using OAuth Protocol.

CloseActivity(String, Guid, String, String, Guid)

Closes the Activity type specified. The Activity Entity type supports fax , letter , and phonecall

*Note: This will default to using English names for Status. if you need to use Non-English, you should populate the names for completed for the status and state.

CloseIncident(Guid, Dictionary<String,CrmDataTypeWrapper>, Int32, Guid)

Closes an Incident request in CRM, this special handling is necessary to support CRM Built In Object.

CloseOpportunity(Guid, Dictionary<String,CrmDataTypeWrapper>, Int32, Guid)

This will close an opportunity as either Won or lost in CRM

CloseQuote(Guid, Dictionary<String,CrmDataTypeWrapper>, Int32, Guid)

Closes a quote as won or lost, Revise is not supported via this method

CloseTroubleTicket(Guid, String, String, Guid)

Closes a Trouble ticket by ID

Create(Entity)

Issues a Create request to CRM

CreateAnnotation(String, Guid, Dictionary<String,CrmDataTypeWrapper>, Guid)

This creates a annotation [note] entry, related to a an existing entity

Required Properties in the fieldList

notetext (string) = Text of the note,

subject (string) = this is the title of the note

CreateBatchOperationRequest(String, Boolean, Boolean)

Create a Batch Request for executing batch operations. This returns an ID that will be used to identify a request as a batch request vs a "normal" request.

CreateEntityAssociation(String, Guid, String, Guid, String, Guid)

Associates one Entity to another where an M2M Relationship Exists.

CreateMultiEntityAssociation(String, Guid, String, List<Guid>, String, Guid, Boolean)

Associates multiple entities of the same time to a single entity

CreateNewActivityEntry(String, String, Guid, String, String, String, Dictionary<String,CrmDataTypeWrapper>, Guid)

Creates a new activity against the target entity type

CreateNewRecord(String, Dictionary<String,CrmDataTypeWrapper>, String, Boolean, Guid)

Uses the dynamic entity patter to create a new entity

CreateOrUpdatePickListElement(String, String, List<LocalizedLabel>, Int32, Boolean)

Adds an option to a pick list on an entity.

Delete(String, Guid)

Issues a Delete request to crm

DeleteAndPromoteSolutionAsync(String)

Executes a Delete and Propmote Request against CRM using the Async Pattern.

DeleteEntity(String, Guid, Guid)

Deletes an entity from the CRM

DeleteEntityAssociation(String, Guid, String, Guid, String, Guid)

Removes the Association between 2 entity items where an M2M Relationship Exists.

Disassociate(String, Guid, Relationship, EntityReferenceCollection)

Issues a Disassociate Request to CRM.

DiscoverGlobalOrganizations(Uri, ClientCredentials, UserIdentifier, String, Uri, String, Boolean, String, PromptBehavior, Boolean)

Discovers the organizations, used for OAuth.

DiscoverOrganizations(Uri, ClientCredentials, UserIdentifier, String, Uri, String, Boolean, String, PromptBehavior, Boolean)

Discovers the organizations, used for OAuth.

DiscoverOrganizations(Uri, Uri, ClientCredentials, ClientCredentials)

Discovers the organizations.

DiscoverOrganizations(Uri, Uri, NetworkCredential)

Discovers the organizations.

Dispose()

Disposed the resources used by the CrmService Client.

Execute(OrganizationRequest)

Executes a general organization request

ExecuteBatch(Guid)

Begins running the Batch command.

ExecuteCrmEntityDeleteRequest(String, Guid, String)

Executes a row level delete on a CRM entity ( thread safe ) and returns true or false. Also adds metrics for logging support.

ExecuteCrmOrganizationRequest(OrganizationRequest, String)

Executes a CRM Organization Request (thread safe) and returns the organization response object. Also adds metrics for logging support.

ExecuteCrmWebRequest(HttpMethod, String, String, Dictionary<String,List<String>>, String)

Executes a web request against the Dataverse Web API.

ExecuteWorkflowOnEntity(String, Guid, Guid)

Executes a named workflow on an object.

GetActivitiesBy(String, Guid, List<String>, CrmServiceClient+LogicalSearchOperator, Dictionary<String,String>, Dictionary<String,CrmServiceClient.LogicalSortOrder>, Int32, Int32, String, String, Boolean, Guid)

Returns all Activities Related to a given Entity ID. Only Account, Contact and Opportunity entities are supported.

GetActivitiesBy(String, Guid, List<String>, CrmServiceClient+LogicalSearchOperator, List<CrmServiceClient.CrmSearchFilter>, Dictionary<String,CrmServiceClient.LogicalSortOrder>, Int32, Int32, String, String, Boolean, Guid)

Returns all Activities Related to a given Entity ID. Only Account, Contact and Opportunity entities are supported.

GetAllAttributesForEntity(String)

Returns all attributes on a entity

GetAllEntityMetadata(Boolean, EntityFilters)

Returns a list of entities with basic data from CRM

GetAllLogs()

Enabled only if InMemoryLogCollectionEnabled is true. Return all logs currently stored for the crmserviceclient in queue.

GetAllLogsAsStringList()

Enabled only if InMemoryLogCollectionEnabled is true. Return all logs currently stored for the crmserviceclient in queue in string list format with [UTCDateTime][LogEntry].

GetBatchById(Guid)

TEMP

GetBatchOperationIdRequestByName(String)

Returns the batch id for a given batch name.

GetBatchRequestAtPosition(Guid, Int32)

Returns the organization request at a give position

GetDataByKeyFromResultsSet<T>(Dictionary<String,Object>, String)

This function gets data from a Dictionary object, where "string" identifies the field name, and Object contains the data, this method then attempts to cast the result to the Type requested, if it cannot be cast an empty object is returned.

GetEntityAttributeMetadataForAttribute(String, String)

Gets metadata for a specific entity's attribute.

GetEntityDataByFetchSearch(String, Guid)

Searches for data based on a FetchXML query

GetEntityDataByFetchSearch(String, Int32, Int32, String, String, Boolean, Guid)

Searches for data based on a FetchXML query

GetEntityDataByFetchSearchEC(String, Guid)

Searches for data based on a FetchXML query

GetEntityDataByFetchSearchEC(String, Int32, Int32, String, String, Boolean, Guid)

Searches for data based on a FetchXML query

GetEntityDataById(String, Guid, List<String>, Guid)

Gets a List of variables from the account based on the list of field specified in the Fields List

GetEntityDataByLinkedSearch(String, Dictionary<String,String>, String, Dictionary<String,String>, String, String, String, CrmServiceClient+LogicalSearchOperator, List<String>, Guid)

Queries an Object via a M to M Link

GetEntityDataByLinkedSearch(String, List<CrmServiceClient.CrmSearchFilter>, String, List<CrmServiceClient.CrmSearchFilter>, String, String, String, CrmServiceClient+LogicalSearchOperator, List<String>, Guid, Boolean)

Queries an Object via a M to M Link

GetEntityDataByRollup(String, Guid, String, List<String>, CrmServiceClient+LogicalSearchOperator, Dictionary<String,String>, Dictionary<String,CrmServiceClient.LogicalSortOrder>, Guid)

Returns all Activities Related to a given Entity ID. Only Account, Contact and Opportunity entities are supported.

GetEntityDataByRollup(String, Guid, String, List<String>, CrmServiceClient+LogicalSearchOperator, List<CrmServiceClient.CrmSearchFilter>, Dictionary<String,CrmServiceClient.LogicalSortOrder>, Int32, Int32, String, String, Boolean, Guid)

Returns all Activities Related to a given Entity ID. Only Account, Contact and Opportunity entities are supported.

GetEntityDataBySearchParams(String, Dictionary<String,String>, CrmServiceClient+LogicalSearchOperator, List<String>, Guid)

Gets a list of accounts based on the search parameters.

GetEntityDataBySearchParams(String, List<CrmServiceClient.CrmSearchFilter>, CrmServiceClient+LogicalSearchOperator, List<String>, Dictionary<String, CrmServiceClient.LogicalSortOrder>, Int32, Int32, String, String, Boolean, Guid)

Searches for data from an entity based on the search parameters.

GetEntityDataBySearchParams(String, List<CrmServiceClient.CrmSearchFilter>, CrmServiceClient+LogicalSearchOperator, List<String>, Guid)

Gets a list of accounts based on the search parameters.

GetEntityDisplayName(String, Int32)

Gets an Entity Name by Logical name or Type code.

GetEntityDisplayNamePlural(String, Int32)

Gets an Entity Name by Logical name or Type code.

GetEntityFormIdListByType(String, CrmServiceClient+FormTypeId)

Returns the Form Entity References for a given form type.

GetEntityMetadata(String, EntityFilters)

Returns the Metadata for an entity from CRM, defaults to basic data only.

GetEntityName(Int32)

Returns the Entity name for the given Type code

GetEntityTypeCode(String)

Gets the typecode of an entity by name.

GetGlobalOptionSetMetadata(String)

Gets a global option set from CRM.

GetMyCrmUserId()

Returns the user ID of the currently logged in user.

GetPickListElementFromMetadataEntity(String, String)

Gets a PickList, Status List or StateList from the metadata of an attribute

ImportDataMapToCrm(String, Boolean, Boolean)

Used to upload a data map to the CRM

ImportSolutionAsync(Guid, Guid, Boolean, Boolean, Boolean, Boolean, Boolean, Dictionary<String,Object>)

Import a solution using the asynchronous service.

ImportSolutionToCrm(Guid, Guid, Boolean, Boolean, Boolean, Boolean, Boolean, Dictionary<String,Object>)

Imports a solution to the CRM server currently connected.

ImportSolutionToCrm(String, Guid, Boolean, Boolean, Boolean, Boolean, Boolean, Dictionary<String,Object>)

Imports a solution to the CRM Server currently connected.

ImportSolutionToCrmAsync(String, Guid, Boolean, Boolean, Boolean, Boolean, Boolean, Dictionary<String,Object>)

Imports a solution to the CRM Server currently connected using an asynchronous job.

InstallSampleDataToCrm()

Request CRM to install sample data shipped with CRM. Note this is process will take a few moments to execute.

This method will return once the request has been submitted.

IsSampleDataInstalled()

Determines if the CRM sample data has been installed

MakeSecureString(String)

Makes a secure string

PublishEntity(String)

Publishes an entity to the production system, used in conjunction with the Metadata services.

ReleaseBatchInfoById(Guid)

Release a batch from the stack Once you have completed using a batch, you must release it from the system.

RemoveOAuthTokenCache(String)

Clear the persistent and in-memory store cache

ResetLocalMetadataCache(String)

This will clear the Metadata cache for either all entities or the specified entity

Retrieve(String, Guid, ColumnSet)

Issues a Retrieve Request to CRM

RetrieveBatchResponse(Guid)

Executes the batch command and then parses the retrieved items into a list. If there exists a exception then the LastException would be filled with the first item that has the exception.

RetrieveMultiple(QueryBase)

Issues a RetrieveMultiple Request to CRM

SendSingleEmail(Guid, String, Guid)

this will send an Email to the

StageSolution(String, MemoryStream)

Stages a solution.

SubmitImportRequest(CrmServiceClient+ImportRequest, DateTime)

Starts an Import request for CRM.

Supports a single file per Import request.

UninstallSampleDataFromCrm()

Request CRM to remove sample data shipped with CRM. Note this is process will take a few moments to execute. This method will return once the request has been submitted.

Update(Entity)

Issues an update to CRM.

UpdateEntity(String, String, Guid, Dictionary<String,CrmDataTypeWrapper>, String, Boolean, Guid)

Generic update entity

UpdateStateAndStatusForEntity(String, Guid, Int32, Int32, Guid)

Updates the State and Status of the Entity passed in.

UpdateStateAndStatusForEntity(String, Guid, String, String, Guid)

Updates the State and Status of the Entity passed in.

Applies to