Plug-in

C# Create a CRM record using the OrganizationServiceContext

C#Plug-in  , , , ,

[vc_row][vc_column css=”.vc_custom_1485102809783{margin-top: 0px !important;border-top-width: 0px !important;padding-top: 0px !important;}”][vc_wp_text]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.[/vc_wp_text][cq_vc_tabs rotatetabs=”0″][cq_vc_tab_item tabicon=”entypo” icon_entypo=”entypo-icon entypo-icon-code” tabtitle=”Code”]

[/cq_vc_tab_item][cq_vc_tab_item tabicon=”entypo” icon_entypo=”entypo-icon entypo-icon-info” tabtitle=”Information”][/cq_vc_tab_item][/cq_vc_tabs][vc_wp_text][/vc_wp_text][/vc_column][/vc_row]

Read details

C# Create a CRM record using Early Binding

C#Plug-in  , , , , ,

[vc_row][vc_column css=”.vc_custom_1485102809783{margin-top: 0px !important;border-top-width: 0px !important;padding-top: 0px !important;}”][vc_wp_text]The following snippet demonstrates how to create a record in C# using Early Binding.[/vc_wp_text][cq_vc_tabs rotatetabs=”0″][cq_vc_tab_item tabicon=”entypo” icon_entypo=”entypo-icon entypo-icon-code” tabtitle=”Code”]

[/cq_vc_tab_item][cq_vc_tab_item tabicon=”entypo” icon_entypo=”entypo-icon entypo-icon-info” tabtitle=”Information”][/cq_vc_tab_item][/cq_vc_tabs][vc_wp_text]To generate early bound classes, use the Microsoft Tool (CrmSvcUtil.exe): https://msdn.microsoft.com/en-us/library/gg327844.aspx[/vc_wp_text][/vc_column][/vc_row]

Read details

C# Create a CRM record using Late Binding

C#Plug-in  , , , , ,

[vc_row][vc_column][vc_wp_text]The following snippet demonstrates how to create a record in C# using Late Binding.[/vc_wp_text][cq_vc_tabs rotatetabs=”0″][cq_vc_tab_item tabicon=”entypo” icon_entypo=”entypo-icon entypo-icon-code” tabtitle=”Code”]

[/cq_vc_tab_item][cq_vc_tab_item tabicon=”entypo” icon_entypo=”entypo-icon entypo-icon-info” tabtitle=”Information”][/cq_vc_tab_item][/cq_vc_tabs][vc_wp_text][/vc_wp_text][/vc_column][/vc_row]

Read details

Message: lose – (Primary Entity: Opportunity)

Plug-in  ,

[vc_row][vc_column][vc_column_text] SUMMARY [/vc_column_text][vc_separator][vc_empty_space height=”15px”][vc_column_text]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.

[/vc_column_text][vc_empty_space height=”80px”][/vc_column][/vc_row][vc_row css=”.vc_custom_1441482115526{margin-top: 0px !important;margin-right: 0px !important;margin-bottom: 0px !important;margin-left: 0px !important;border-top-width: 0px !important;border-right-width: 0px !important;border-bottom-width: 0px !important;border-left-width: 0px !important;padding-top: 0px !important;padding-right: 0px !important;padding-bottom: 0px !important;padding-left: 0px !important;}”][vc_column][vc_column_text]CODE EXAMPLES[/vc_column_text][vc_separator][vc_empty_space height=”10px”][vc_tour interval=”0″][vc_tab title=”CODE” tab_id=”1441477385-1-6″][vc_wp_text]

[/vc_wp_text][/vc_tab][vc_tab title=”Code Examples” tab_id=”1441480478401-1-8″][vc_wp_text]

[/vc_wp_text][/vc_tab][vc_tab title=”SDK Code Example” tab_id=”1441489788797-3-9″][vc_wp_text]

[/vc_wp_text][/vc_tab][vc_tab title=”SDK Information” tab_id=”1441627538859-4-3″][vc_wp_text] No additional information. [/vc_wp_text][/vc_tab][vc_tab title=”Notes” tab_id=”1441480494692-2-9″][vc_wp_text] No additional information. [/vc_wp_text][/vc_tab][/vc_tour][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]MORE INFORMATION[/vc_column_text][vc_separator][vc_empty_space height=”10px”][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]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. [/vc_column_text][vc_wp_tagcloud title=” ” taxonomy=”my-product_category”][/vc_column][/vc_row]

Read details

Message: win – (Primary Entity: Opportunity)

Plug-in  ,

[vc_row][vc_column][vc_column_text] SUMMARY [/vc_column_text][vc_separator][vc_empty_space height=”15px”][vc_column_text]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.

[/vc_column_text][vc_empty_space height=”80px”][/vc_column][/vc_row][vc_row css=”.vc_custom_1441482115526{margin-top: 0px !important;margin-right: 0px !important;margin-bottom: 0px !important;margin-left: 0px !important;border-top-width: 0px !important;border-right-width: 0px !important;border-bottom-width: 0px !important;border-left-width: 0px !important;padding-top: 0px !important;padding-right: 0px !important;padding-bottom: 0px !important;padding-left: 0px !important;}”][vc_column][vc_column_text]CODE EXAMPLES[/vc_column_text][vc_separator][vc_empty_space height=”10px”][vc_tour interval=”0″][vc_tab title=”CODE” tab_id=”1441477385-1-6″][vc_wp_text]

[/vc_wp_text][/vc_tab][vc_tab title=”Code Examples” tab_id=”1441480478401-1-8″][vc_wp_text]

[/vc_wp_text][/vc_tab][vc_tab title=”SDK Code Example” tab_id=”1441489788797-3-9″][vc_wp_text]

[/vc_wp_text][/vc_tab][vc_tab title=”SDK Information” tab_id=”1441627538859-4-3″][vc_wp_text] No additional information. [/vc_wp_text][/vc_tab][vc_tab title=”Notes” tab_id=”1441480494692-2-9″][vc_wp_text] No additional information. [/vc_wp_text][/vc_tab][/vc_tour][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]MORE INFORMATION[/vc_column_text][vc_separator][vc_empty_space height=”10px”][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]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. [/vc_column_text][vc_wp_tagcloud title=” ” taxonomy=”my-product_category”][/vc_column][/vc_row]

Read details

Set State (Activate /Deactivate) record

Plug-in 

[vc_row][vc_column][vc_column_text] SUMMARY [/vc_column_text][vc_separator][vc_empty_space height=”15px”][vc_column_text]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.

[/vc_column_text][vc_empty_space height=”80px”][/vc_column][/vc_row][vc_row css=”.vc_custom_1441482115526{margin-top: 0px !important;margin-right: 0px !important;margin-bottom: 0px !important;margin-left: 0px !important;border-top-width: 0px !important;border-right-width: 0px !important;border-bottom-width: 0px !important;border-left-width: 0px !important;padding-top: 0px !important;padding-right: 0px !important;padding-bottom: 0px !important;padding-left: 0px !important;}”][vc_column][vc_column_text]CODE EXAMPLES[/vc_column_text][vc_separator][vc_empty_space height=”10px”][vc_tour interval=”0″][vc_tab title=”CODE” tab_id=”1441477385-1-6″][vc_wp_text]

[/vc_wp_text][/vc_tab][vc_tab title=”Code Examples” tab_id=”1441480478401-1-8″][vc_wp_text]

[/vc_wp_text][/vc_tab][vc_tab title=”SDK Code Example” tab_id=”1441489788797-3-9″][vc_wp_text]

[/vc_wp_text][/vc_tab][vc_tab title=”SDK Information” tab_id=”1441627538859-4-3″][vc_wp_text] No additional information. [/vc_wp_text][/vc_tab][vc_tab title=”Notes” tab_id=”1441480494692-2-9″][vc_wp_text] No additional information. [/vc_wp_text][/vc_tab][/vc_tour][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]MORE INFORMATION[/vc_column_text][vc_separator][vc_empty_space height=”50px”][vc_wp_tagcloud title=” ” taxonomy=”my-product_category”][/vc_column][/vc_row]

Read details

Plug-in CRUD Operations

Plug-in  , , , ,

[vc_row][vc_column][vc_column_text] Summary [/vc_column_text][vc_separator][vc_column_text]CRM versions: Latest versions including CRM 2015, 2013, 2011[/vc_column_text][vc_empty_space height=”15px”][vc_column_text]CRUD Operations for Microsoft Dynamics CRM.[/vc_column_text][vc_empty_space height=”50px”][/vc_column][/vc_row][vc_row][vc_column][vc_column_text] CODE [/vc_column_text][vc_separator][vc_empty_space height=”15px”][/vc_column][/vc_row][vc_row css=”.vc_custom_1441482115526{margin-top: 0px !important;margin-right: 0px !important;margin-bottom: 0px !important;margin-left: 0px !important;border-top-width: 0px !important;border-right-width: 0px !important;border-bottom-width: 0px !important;border-left-width: 0px !important;padding-top: 0px !important;padding-right: 0px !important;padding-bottom: 0px !important;padding-left: 0px !important;}”][vc_column][vc_tour interval=”0″][vc_tab title=”CODE” tab_id=”1441477385-1-6″][vc_wp_text title=”Create (Late binding)”]

[/vc_wp_text][/vc_tab][vc_tab title=”Code Examples” tab_id=”1441480478401-1-8″][vc_wp_text]

[/vc_wp_text][/vc_tab][vc_tab title=”SDK Code Example” tab_id=”1441489788797-3-9″][vc_wp_text]

[/vc_wp_text][/vc_tab][vc_tab title=”SDK Information” tab_id=”1441627538859-4-3″][vc_wp_text] No additional information. [/vc_wp_text][/vc_tab][vc_tab title=”Notes” tab_id=”1441480494692-2-9″][vc_wp_text] No additional information. [/vc_wp_text][/vc_tab][/vc_tour][/vc_column][/vc_row][vc_row css=”.vc_custom_1441482115526{margin-top: 0px !important;margin-right: 0px !important;margin-bottom: 0px !important;margin-left: 0px !important;border-top-width: 0px !important;border-right-width: 0px !important;border-bottom-width: 0px !important;border-left-width: 0px !important;padding-top: 0px !important;padding-right: 0px !important;padding-bottom: 0px !important;padding-left: 0px !important;}”][vc_column][vc_tour interval=”0″][vc_tab title=”CODE” tab_id=”1441477385-1-6″][vc_wp_text title=”Create (Early binding)”]

[/vc_wp_text][/vc_tab][vc_tab title=”Code Examples” tab_id=”1441480478401-1-8″][vc_wp_text]

[/vc_wp_text][/vc_tab][vc_tab title=”SDK Code Example” tab_id=”1441489788797-3-9″][vc_wp_text]

[/vc_wp_text][/vc_tab][vc_tab title=”SDK Information” tab_id=”1441627538859-4-3″][vc_wp_text] No additional information. [/vc_wp_text][/vc_tab][vc_tab title=”Notes” tab_id=”1441480494692-2-9″][vc_wp_text] No additional information. [/vc_wp_text][/vc_tab][/vc_tour][/vc_column][/vc_row][vc_row css=”.vc_custom_1441482115526{margin-top: 0px !important;margin-right: 0px !important;margin-bottom: 0px !important;margin-left: 0px !important;border-top-width: 0px !important;border-right-width: 0px !important;border-bottom-width: 0px !important;border-left-width: 0px !important;padding-top: 0px !important;padding-right: 0px !important;padding-bottom: 0px !important;padding-left: 0px !important;}”][vc_column][vc_tour interval=”0″][vc_tab title=”CODE” tab_id=”1441477385-1-6″][vc_wp_text title=”Create method using the OrganizationServiceContext”]

[/vc_wp_text][/vc_tab][vc_tab title=”Code Examples” tab_id=”1441480478401-1-8″][vc_wp_text]

[/vc_wp_text][/vc_tab][vc_tab title=”SDK Code Example” tab_id=”1441489788797-3-9″][vc_wp_text]

[/vc_wp_text][/vc_tab][vc_tab title=”SDK Information” tab_id=”1441627538859-4-3″][vc_wp_text] No additional information. [/vc_wp_text][/vc_tab][vc_tab title=”Notes” tab_id=”1441480494692-2-9″][vc_wp_text title=”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.[/vc_wp_text][/vc_tab][/vc_tour][/vc_column][/vc_row][vc_row css=”.vc_custom_1441482115526{margin-top: 0px !important;margin-right: 0px !important;margin-bottom: 0px !important;margin-left: 0px !important;border-top-width: 0px !important;border-right-width: 0px !important;border-bottom-width: 0px !important;border-left-width: 0px !important;padding-top: 0px !important;padding-right: 0px !important;padding-bottom: 0px !important;padding-left: 0px !important;}”][vc_column][vc_tour interval=”0″][vc_tab title=”CODE” tab_id=”1441477385-1-6″][vc_wp_text title=”Retrieve (Service.Retrieve)”]

[/vc_wp_text][/vc_tab][vc_tab title=”Code Examples” tab_id=”1441480478401-1-8″][vc_wp_text]

[/vc_wp_text][/vc_tab][vc_tab title=”SDK Code Example” tab_id=”1441489788797-3-9″][vc_wp_text]

[/vc_wp_text][/vc_tab][vc_tab title=”SDK Information” tab_id=”1441627538859-4-3″][vc_wp_text] No additional information. [/vc_wp_text][/vc_tab][vc_tab title=”Notes” tab_id=”1441480494692-2-9″][vc_wp_text] No additional information. [/vc_wp_text][/vc_tab][/vc_tour][/vc_column][/vc_row][vc_row css=”.vc_custom_1441482115526{margin-top: 0px !important;margin-right: 0px !important;margin-bottom: 0px !important;margin-left: 0px !important;border-top-width: 0px !important;border-right-width: 0px !important;border-bottom-width: 0px !important;border-left-width: 0px !important;padding-top: 0px !important;padding-right: 0px !important;padding-bottom: 0px !important;padding-left: 0px !important;}”][vc_column][vc_tour interval=”0″][vc_tab title=”CODE” tab_id=”1441477385-1-6″][vc_wp_text title=”RetrieveMultiple (QueryByAttribute)”]

[/vc_wp_text][/vc_tab][vc_tab title=”Code Examples” tab_id=”1441480478401-1-8″][vc_wp_text]

[/vc_wp_text][/vc_tab][vc_tab title=”SDK Code Example” tab_id=”1441489788797-3-9″][vc_wp_text]

[/vc_wp_text][/vc_tab][vc_tab title=”SDK Information” tab_id=”1441627538859-4-3″][vc_wp_text] No additional information. [/vc_wp_text][/vc_tab][vc_tab title=”Notes” tab_id=”1441480494692-2-9″][vc_wp_text] No additional information. [/vc_wp_text][/vc_tab][/vc_tour][/vc_column][/vc_row][vc_row

Read details

Nullable Types and CRM

Plug-in 

[vc_row][vc_column][vc_column_text] Summary [/vc_column_text][vc_empty_space height=”15px”][vc_column_text]Set CRM attributes (int, bool, OptionSet) to null.

Read details

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

Plug-in 

[vc_row][vc_column][vc_column_text] Summary [/vc_column_text][vc_empty_space][vc_column_text]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. [/vc_column_text][vc_empty_space][vc_column_text] Example: [/vc_column_text][vc_single_image image=”5399″ img_size=”1000×1681″][vc_empty_space][vc_column_text] Code Example [/vc_column_text][vc_empty_space][/vc_column][/vc_row][vc_row css=”.vc_custom_1441482115526{margin-top: 0px !important;margin-right: 0px !important;margin-bottom: 0px !important;margin-left: 0px !important;border-top-width: 0px !important;border-right-width: 0px !important;border-bottom-width: 0px !important;border-left-width: 0px !important;padding-top: 0px !important;padding-right: 0px !important;padding-bottom: 0px !important;padding-left: 0px !important;}”][vc_column][vc_tour interval=”0″][vc_tab title=”CODE” tab_id=”1441477385-1-6″][vc_wp_text]

[/vc_wp_text][/vc_tab][vc_tab title=”Code Examples” tab_id=”1441480478401-1-8″][vc_wp_text]

[/vc_wp_text][/vc_tab][vc_tab title=”SDK Code Example” tab_id=”1441489788797-3-9″][vc_wp_text]

[/vc_wp_text][/vc_tab][vc_tab title=”SDK Information” tab_id=”1441627538859-4-3″][vc_wp_text] No additional information. [/vc_wp_text][/vc_tab][vc_tab title=”Notes” tab_id=”1441480494692-2-9″][vc_wp_text] 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. [/vc_wp_text][/vc_tab][/vc_tour][/vc_column][/vc_row][vc_row][vc_column][vc_wp_tagcloud title=” ” taxonomy=”my-product_category”][/vc_column][/vc_row]

Read details

QueryByAttribute (QueryExpression) Example

Plug-in  ,

[vc_row][vc_column][vc_column_text] Summary [/vc_column_text][vc_empty_space][vc_column_text]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.[/vc_column_text][vc_empty_space][vc_column_text] Code Example [/vc_column_text][vc_empty_space][/vc_column][/vc_row][vc_row css=”.vc_custom_1441482115526{margin-top: 0px !important;margin-right: 0px !important;margin-bottom: 0px !important;margin-left: 0px !important;border-top-width: 0px !important;border-right-width: 0px !important;border-bottom-width: 0px !important;border-left-width: 0px !important;padding-top: 0px !important;padding-right: 0px !important;padding-bottom: 0px !important;padding-left: 0px !important;}”][vc_column][vc_tour interval=”0″][vc_tab title=”CODE” tab_id=”1441477385-1-6″][vc_wp_text]

[/vc_wp_text][/vc_tab][vc_tab title=”Code Examples” tab_id=”1441480478401-1-8″][vc_wp_text]

[/vc_wp_text][/vc_tab][vc_tab title=”SDK Code Example” tab_id=”1441489788797-3-9″][vc_wp_text]

[/vc_wp_text][/vc_tab][vc_tab title=”SDK Information” tab_id=”1441627538859-4-3″][vc_wp_text] No additional information. [/vc_wp_text][/vc_tab][vc_tab title=”Notes” tab_id=”1441480494692-2-9″][vc_wp_text] 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. [/vc_wp_text][/vc_tab][/vc_tour][/vc_column][/vc_row][vc_row][vc_column][vc_wp_tagcloud title=” ” taxonomy=”my-product_category”][/vc_column][/vc_row]

Read details