Plug-in

C# Create a CRM record using the OrganizationServiceContext

C#Plug-in  , , , ,
The following snippet demonstrates how to create a record in C# using the OrganizationServiceContext. The method allows for multiple records to be added to an object before committing to a save. Code Information
Read details

C# Create a CRM record using Early Binding

C#Plug-in  , , , , ,
The following snippet demonstrates how to create a record in C# using Early Binding. Code Information To generate early bound classes, use the Microsoft Tool (CrmSvcUtil.exe): https://msdn.microsoft.com/en-us/library/gg327844.aspx
Read details

C# Create a CRM record using Late Binding

C#Plug-in  , , , , ,
The following snippet demonstrates how to create a record in C# using Late Binding. Code Information
Read details

Message: lose – (Primary Entity: Opportunity)

Plug-in  ,
SUMMARY This code example demonstrates code that fires on the lose message of an Opportunity entity. The code checks to see if an attribute in the current opportunity record is not null, if the attribute is null, an exception is thrown. Plug-in is registered on the win message. CODE EXAMPLES CODECode ExamplesSDK Code ExampleSDK InformationNotes No additional information. No additional information. Previous tab Next tab MORE INFORMATION Using the debugger and attaching to the wpw3.exe on the CRM server allows us to debug the plug-in at runtime. This allows us to monitor the InputParameters to discover the current entity that fired the plug-in (OpportunityClose). The values from the InputParameters (Keys[0]) provides the reference to the originating Opportunity record. The results view in the debugger illustrates that the GUID, LogicalName is provided for opportunityid. C# JavaScript LINQ Plug-in PowerShell SQL Troubleshooting Web Resources
Read details

Message: win – (Primary Entity: Opportunity)

Plug-in  ,
SUMMARY This code example demonstrates code that fires on the win message of an Opportunity entity. The code checks to see if an attribute in the current opportunity record is not null, if the attribute is null, an exception is thrown. Plug-in is registered on the win message. CODE EXAMPLES CODECode ExamplesSDK Code ExampleSDK InformationNotes No additional information. No additional information. Previous tab Next tab MORE INFORMATION Using the debugger and attaching to the wpw3.exe on the CRM server allows us to debug the plug-in at runtime. This allows us to monitor the InputParameters to discover the current entity that fired the plug-in (OpportunityClose). The values from the InputParameters (Keys[0]) provides the reference to the originating Opportunity record. The results view in the debugger illustrates that the GUID, LogicalName is provided for opportunityid. C# JavaScript LINQ Plug-in PowerShell SQL Troubleshooting Web Resources
Read details

Set State (Activate /Deactivate) record

Plug-in 
SUMMARY Plug-in fires on the change of a record status or activate/deactivate of a record. Must be registered on both the SetState & SetStateDynamicEntity messages. CODE EXAMPLES CODECode ExamplesSDK Code ExampleSDK InformationNotes No additional information. No additional information. Previous tab Next tab MORE INFORMATION C# JavaScript LINQ Plug-in PowerShell SQL Troubleshooting Web Resources
Read details

Plug-in CRUD Operations

Plug-in  , , , ,
Summary CRM versions: Latest versions including CRM 2015, 2013, 2011 CRUD Operations for Microsoft Dynamics CRM. CODE CODECode ExamplesSDK Code ExampleSDK InformationNotes Create (Late binding) No additional information. No additional information. Previous tab Next tab CODECode ExamplesSDK Code ExampleSDK InformationNotes Create (Early binding) No additional information. No additional information. Previous tab Next tab CODECode ExamplesSDK Code ExampleSDK InformationNotes Create method using the OrganizationServiceContext No additional information. SDK Remarks The organization service context class maintains state on the client between interactions with the Microsoft Dynamics CRM Web service to support features such as change management. This class also manages identities and tracks changes to Microsoft Dynamics CRM data. The organization service context class implements the IQueryable interface and a .NET Language-Integrated Query (LINQ) query provider so you can write LINQ queries against Microsoft Dynamics CRM data. Objects tracked by the organization service context are instances of entity types that represent data in Microsoft Dynamics CRM. You can designate actions to be performed on these objects and the service context tracks the changes. When the SaveChanges method is called, the service context instructs Microsoft Dynamics CRM to generate commands to create, update or delete the entities the tracked objects represent. The code generation tool (CrmSvcUtil.exe) can be used to create a custom instance of theOrganizationServiceContext class. This class includes customizations and provides helper properties and methods for working with entities. Several enumerations are used with the OrganizationServiceContext class. The MergeOption enumeration indicates how changes are applied to Microsoft Dynamics CRM data. The SaveChangesOptions enumeration determines how changes are managed by the service context if an error occurs. Previous tab Next tab CODECode ExamplesSDK Code ExampleSDK InformationNotes Retrieve (Service.Retrieve) No additional information. No additional information. Previous tab Next tab CODECode ExamplesSDK Code ExampleSDK InformationNotes RetrieveMultiple (QueryByAttribute) No additional information. No additional information. Previous tab Next tab CODECode ExamplesSDK Code ExampleSDK InformationNotes RetrieveMultiple (QueryExpression) No additional information. No additional information. Previous tab Next tab CODECode ExamplesSDK Code ExampleSDK InformationNotes Update No additional information. No additional information. Previous tab Next tab CODECode ExamplesSDK Code ExampleSDK InformationNotes Delete No additional information. No additional information. Previous tab Next tab C# JavaScript LINQ Plug-in PowerShell SQL Troubleshooting Web Resources
Read details

Nullable Types and CRM

Plug-in 

Set CRM attributes (int, bool, OptionSet) to null.

Read details

QueryByAttribute: Get a value from one Lookup & populate another Lookup

Plug-in 
Summary The example demonstrates how to query a CRM entity using QueryByAttribute. In this example three entities exist: Purchase Product Nominal Product & Nominal are Lookup attributes on the Purchase form. In the code example, we have assumed that there is a requirement to have the Nominal Lookup automatically populated on the creation of a new record. The Nominal lookup is populated with a record that matches the Product ID. The Code works as follows: The Product lookup is queried, the Product ID is extracted. The Product ID is matched against the Name of a Nominal record. Once found, the Lookup is automatically populated. Example: Code Example CODECode ExamplesSDK Code ExampleSDK InformationNotes No additional information. Property Description EntityName Specifies which type of entity is retrieved. A query expression can only retrieve a collection of one entity type. You can also pass this value by using the QueryExpression constructor. ColumnSet Specifies the set of attributes (columns) to retrieve. Attributes Specifies the set of attributes selected in the query. Values Specifies the attribute values to look for when the query is executed. Orders Specifies the order in which the records are returned from the query. PageInfo Specifies the number of pages and the number of records per page returned from the query. Previous tab Next tab C# JavaScript LINQ Plug-in PowerShell SQL Troubleshooting Web Resources
Read details

QueryByAttribute (QueryExpression) Example

Plug-in  ,
Summary In Microsoft Dynamics CRM 2015 and Microsoft Dynamics CRM Online 2015 Update, you can use the QueryByAttributeclass to build queries that test a set of attributes against a set of values. Use this class with the RetrieveMultiple method or the IOrganizationService.RetrieveMultipleRequest method. Code Example CODECode ExamplesSDK Code ExampleSDK InformationNotes No additional information. Property Description EntityName Specifies which type of entity is retrieved. A query expression can only retrieve a collection of one entity type. You can also pass this value by using the QueryExpression constructor. ColumnSet Specifies the set of attributes (columns) to retrieve. Attributes Specifies the set of attributes selected in the query. Values Specifies the attribute values to look for when the query is executed. Orders Specifies the order in which the records are returned from the query. PageInfo Specifies the number of pages and the number of records per page returned from the query. Previous tab Next tab C# JavaScript LINQ Plug-in PowerShell SQL Troubleshooting Web Resources
Read details