Posts

Showing posts from 2016

How to Set field values in CRM through parameters passed to a new form using JavaScript

Image
In this blog I am showing how we can add default values to the new form when open new form. You can set default values for new records created by users by specifying attribute values in the URL that is used to open the form. For this you need to add a Button placed on the form(Existing Record) and on click of this button we'll copy data to the new form from the existing record. In this example I placed a button of account entity form which is enable only if record exists and on click of this a new form opens with few values copied to new form using parameter passed in URL. Add code as shown below function GetIdFromLookup(lkpFieldSchemaName) {     var lkpField = null;     var sGuid = null;     lkpField = Xrm.Page.data.entity.attributes.get(lkpFieldSchemaName);     if (lkpField != null && lkpField.getValue() != null)         sGuid = lkpField.getValue()[0].id;     return sGuid; } function GetNameFromLookup(lkpFieldSchemaName) {     var lkpField = null;

How to generate PDF/ xls report from .rdlc without using Reporting services in c#.

In this blog, I am going to show how to create a Report dynamically using a DataSet in Report document (*.rdlc). and show the report without much effort. Step 1: Create a Report(.rldc) using SSRS or any other tool. Add appropriate  DataSet and DataSource and with required columns create a table and Bind DataColumns. Once Report created build and Goto Code behind solution. Step 2: Now in the Code behind, add the following codes and required references. Note: I have added just 3 fields report and the same field should be used in code behind also with exact DataSet name as it is in Report. Currently DataSet has hardcode value which you can replace with fetched value from Database. using System.Collections.Generic; using Microsoft.Reporting.WebForms;         #region ReportGenerateFromRDLFile         public static void RenderReport()         {             string sReportPath = string.Empty;             string sExtension = ".xls";             try        

How to create Email activity with dynamically retreived data from Dynamics CRM through Plugin C#

Image
In this blog, I am going to show how we can add dynamically retreived data from CRM in a table and show this data inside a table within the Email body. Apart from adding dynamic data in a table into Email body I have also added code for showing Image which we have saved in web resources inside CRM. In short this blog covers below point: Adding Image from Web Resources Creating HTML formatted table from DataTable Converting EntityCollection into DataTable Showing dynamic data in Email body description  1. First of all below required namespaces in your code(Add required references)  using Microsoft.Crm.Sdk.Messages;  using Microsoft.Xrm.Sdk;  using Microsoft.Xrm.Sdk.Query;  using System;  using System.Collections.Generic;  using System.Data;  using System.Linq;  2. Now Goto your CRM Settings, Add a web resource of type Image.  3. Now Add below codes in the Execute method of your plugin as it is:  public class Class1 : IPlugin    {      public void Execute(IService

AdxStudio Portal development guide. How to Setup, Configure, customize AdxStudio Portal in Microsoft Dynamics CRM? How to add custom JavaScript and .aspx page in AdxStudio

Adxstudio Portals supercharges Dynamics® CRM into an interactive, web-based sales, services, support and social engagement application platform. In this blog you'll come to know the following details related to AdxStudio Portal- Dynamics CRM. A step by step gyide with screenshots how to configure 1. Download and Installation 2. How to Setup and create portal website 3. Creating Custom .aspx page(Page Template) for Portal 4. Adding Custom .aspx page in Portal 5. JavaScript Customization in AdxStudio Web Forms Visit blog for details on above points

How to fetch data from Microsoft Dynamics CRM OnPremise and show them on Gridview with Search, Select, Paging and Sorting feature in Asp.Net, C#

Image
In this blog I am going to show how we can fetch data from Dynamics CRM OnPremise and Show them in a gridview on Web Page. Not only this but also following points: Selecting value of row by clicking anywhere on a row. Searching data in Gridview. Sorting of data in Gridview. Paging in Gridview. First of all take a Textbox for serach box and Gridview on your web page and place below code:: <form id="form1" runat="server">        <script type="text/javascript">        function RefreshParent(row) {          if (window.opener != null && !window.opener.closed) {              var message = "";              message += "Id: " + $("td", row).eq(0).html();              message += "\nName: " + $("td", row).eq(1).html();              alert(message);            window.opener.location.reload();          }        }        window.onbeforeunload = RefreshParent;      </script>

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 () {                 addLookupFilter();             });         }     } catch (e) {         ShowCatchMess

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));        IOrganizationService serviceDefaultUser = factory.CreateOrganizationService(contextPlugin.UserId);          OptionSetValue
go to top image