Posts

Showing posts with the label CRM 2015

How to update related entity records in Dynamics CRM using javascript

In this blog, I am going to show how we can update a related entity record through JScript in DYnamics CRM either REST or OData way. First of all I'll show update data using REST Query in Method 1 and then using OData query in method 2. function btnUpdateOnClick() {     try {         var selectedRows = Xrm.Page.getControl("SubGridName").getGrid().getSelectedRows();         selectedRows.forEach(function (selectedRow, i) {             var s = selectedRow.getData().getEntity().getEntityReference();             var selectedRowGuid = s.id;             var selectedRowName = s.name;             var selectedRowEntityName = s.entityType;             UpdateAccount(selectedRowGuid, selectedRowName, selectedRowEntityName);         });     }   ...

How to add custom filter lookup field based on OptionSet field selection in Dynamics CRM.

Image
In this blog I am going to show how we can filter records based on the selected option set value. For this example I have created an entity and placed 2 fields mainly, One is Option set Field for Region/ Divison and another is Lookup filed of State. So when user will select the region the lookup values will show only filtered records based on the region, copy and paste the code below in your form option set OnChange event which will filter record of lookup. function FilterPackagesLookup() {     try {         preFilterLookup();     } catch (e) {         ShowCatchMessage(e.message);     } } function preFilterLookup() {     try {         if (Xrm.Page.ui.controls.get("new_state") != "undefined" && Xrm.Page.ui.controls.get("new_state") != null) {             Xrm.Page.getControl("new_state").addPreSearch(function () {     ...

Modify Lead Qualification process in Dynamics CRM using C#: How to prevent Opportunity/ Account Creation and Refresh Lead Page On Lead Qualify

One condition on Lead Qualify could be like: If we don't want to create Opportunit/ Account or Contact on Lead Qualification that heppens by default. So for this secnario Below is the code which is required to stop creation of Opportunity/ Account on Qualifying Lead. Note: Register Plugin on "QualifyLead" message and Pre-Operation public void Execute(IServiceProvider serviceProvider)        {        AvoidOpportunityCreationOnLeadQualify(serviceProvider);      }        private void AvoidOpportunityCreationOnLeadQualify(IServiceProvider serviceProvider)      {        IPluginExecutionContext contextPlugin = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));        IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));     ...

How to Get the records when Lead is Qualified in Microsoft Dynamics CRM using Plugin C#

Image
In this blog I am going to explain and show an example when a lead is Qualified then how we can get the new records or we can update records in newly created record when Lead status is Qualified. 1. Register your created plugin in "QualifyLead" message and On Post-Operation to get the records when lead is Qualified. :: 2. Here in this example I am setting up a Lookup field value in newly created Opportunity when lead is Qualified. Just type the code as below and register as said in Step 1.       IOrganizationService serviceDefaultUser = null;             IPluginExecutionContext contextPlugin = GetContext(serviceProvider);             serviceDefaultUser = GetServiceObject(serviceProvider, contextPlugin);             // Get the qualified lead.             EntityReference leadid = (EntityReference)context.InputParameters["LeadId"];  ...

How to retreive CRM records from an Entity using Fetch XML in Dynamics CRM and show on Grid view using c#. How to Bulk delete records from CRM using c#

Image
In this blog I am going to explain how we could retrive/ delete all records from an entity in CRM using C#. For this demo I have taken a windows application, check the below steps and use the code as it is. This code also includes code how we could show Entity data in Gridview. 1. First of all take two different buttons. First button for retreiving records and 2nd button is for deleting records from an entity in CRM. 2. Place a Gridview control too in your form. 3. Now place code as below on Browse, Bulk_Upload button::         OrganizationService _orgservice = new OrganizationService(CrmConnection.Parse("Url=https://yourSolution.crm5.dynamics.com; Username=admin@yourSolution.onmicrosoft.com; Password=pass@word1;"));                   //Retrive All records from an Entity in CRM using ExecuteMultipleRequest         private void btnRtvMultiple_Click(object sender, EventArgs e)   ...

Bulk upload data in Microsoft Dynamics CRM from Excel using c#, How to Import data from Excel in C#

Image
In this blog I am going to explain how we could upload bulk data in CRM from Excel sheet using C#. For this demo I have taken a windows application, check the below steps and use the code as it is. This code also includes code how we could import Excel data. 1. First of all take a textbox and two different buttons. textbox for showing teh selected file path and first button for Browsing file and 2nd button is for uploading Data in CRM. 2. Place a OpenFileDialog control too in your form. 3. Now place code as below on Browse, Bulk_Upload button:: OrganizationServiceProxy _orgservice = CreateCrmServiceObject();               private void btnBrowse_Click(object sender, EventArgs e)         {             DialogResult fd = openFileDialog1.ShowDialog();             if (fd == DialogResult.OK)             {     ...
go to top image