Posts

Showing posts from 2015

How to Call Custom Web service through JavaScript in Asp.Net.

In this post I am going to Show How we can create a web Service and consume it through javascript i.e Calling a web service in Javascript using Asp.Net/ Calling a WebService in Javascript in Microsoft Dynamics CRM. 1. First of all create a web service by going to Visual Studio-> Select New Website-> WebService -> Service.cs 2. Create a new WebMethod or update your HelloWorld WebMethod as below, I have create a sample Web service which accepts 2 parameters and based on that returns a string value: string[,] stocks = { { "Infy", "Infosys", "122.35" }, { "DSS", "Direction", "98.22" } }; [WebMethod] public string getName(string symbol, string Name) { for (int i = 0; i < stocks.GetLength(0); i++) { if (String.Compare(symbol, stocks[i, 0], true) == 0 || String.Compare(Name, stocks[i + 1, 0], true) == 0) { return ("Stock Value of &

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"];             Entity lead = orgSrvService.Retrieve("lead", leadid.Id, new ColumnSet(true));             Entity

How to Merge two excel sheets into one in c#.

Image
In this blog I am going to explain how we could merge two different excel sheets into one using C# programing. For this demo I have taken a console application, check the below steps and use the code as it is. 1. First of all create two different Excel files and put some data into those sheets, remember to RENAME the worksheet name because same name will create Error while processing Merging process. eg., Plz check the encircled area in below images:: 2. Add References. At minimum, you will need below referances. static void Main(string[] args) {   MergeExcelNew(); }     private static void MergeExcelNew() {     Application app = new Microsoft.Office.Interop.Excel.Application();     Workbook bookDest = null;     Worksheet sheetDest = null;     Workbook bookSource = null;     Worksheet sheetSource = null;     string sTempPath = @"D:\Temp\Sheet1_Folder\Sheet1.xlsx";     string sFinalPath = @"D:\Temp\Sheet2_Folder\Sheet2.xlsx";     try     {

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)         {             DataTable dt = new DataTable();             EntityCollection

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)             {                 textBox1.Text = openFileDialog1.FileName;             }         }         //Browse excel file for bulk uploading in CRM         private void btnUpl

How to Create a very Basic Web Service in C# (Visual Studio)

Image
In this blog I am going to show how we could create a very basic Web Service in c#. 1. First of all Open your Visual Studio and GoTo File and Select New Empty Website and rename and open your new empty website. 2. For adding the web service right-click on the solution and then Select Add- Add New Item- Select Web Service(asmx) file, you will get it's class file open as in figure, remove "Hello World" web default method and add code as below:: using System; using System.Web.Services; [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.  // [System.Web.Script.Services.ScriptService] public class Service : System.Web.Services.WebService {     public Service()     {         //Uncomment the following line if using designed components          //InitializeComponent(

Load data in the web page after Page load using Timer and Ajax Update panel for fast downloading of page in c#- Asp.net

Image
In this blog I am going to explain how we could load data asynchronously after Page Load is completed in c#-asp.net i.e loading data post the page load so that if you have some page on click of another page your 2nd page could load very fast. We have seen a lot of case where we click on login button but the page loads very slowly even its design and images took a lot of time. Loading and optimizing code for fast retreival of data is different thing and I am not going to touch that thing in this post. This post is just about loading page fast using Timer control and Update Panel So, first of all place a timer and AJAX- update panel before the gridview in your aspx page which needed to load data asynchronously after page load like below :: <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title></title>     <style type="text/css">          DIV.ProgressBarNew {             width: 150px;          

How to save Image from remote URL, How to save image of Dropbox URL, How to check Image extension is Valid or not, How to check remote URL is valid or not using c# asp.net

Image
In this blog I am going to explain how to save Image from remote URL in your Drive, how to save image of Dropbox URL which is little bit different and few small things like how to check Image extension is Valid or not and how we could check whether remote URL is valid or not using c# asp.net. Apart from these things small things are also there which I have used in this code like how to removes empty elements from an array using LINQ and how to remove special character like semi-colon from elements of array if exists using LINQ. Lot of things are here explained in a very simple and easy to understand way. Paste all code as it is in your new selected project without any changes. Add Drawing referance and few below specified namespaces and don't forget to add Image folder in your base directory and run your code. you will get the result without any error... So, enjoy coding... :) using System.Drawing; using System.Diagnostics; using System.Net; using System.IO; namespace Uplo

Activate/ Deactivate a record using C# in Dynamics CRM 2011/ 2013/ 2015

In this blog I am going to show how we could Activate/ Deactivate a record in Dynamics CRM using c#.  For this we cannot simply activate or deactivate records by simply setting statecode and statuscode in the early bound entity records. To do this, we must use SetStateRequest and SetStateResponse from Microsoft.Crm.Sdk.Proxy assembly. Add all required updated dll referances in your project.                 Below is the methods separately for Activating & Deactivating a record:: public static void DeactivateRecord (Guid recordId, OrganizationServiceProxy organizationService)         {             var EntityName = organizationService.Retrieve("EntityName", recordId, new ColumnSet(new[] { "statecode", "statuscode" }));             try             {                 if (EntityName != null)                 {                     SetStateRequest objSetStateRequest = new SetStateRequest()                     {                         EntityMonik

Difference between WCF and Web Service

   In this blog I am listing few differences between WCF and Web Service. A lot from us gets confused which is the best out these two to use. Please have a look on the below table and find yourself what to choose and why. WebService WCF           ·   WebService and WebMethod attributes are used for defining web service.            ·   ServiceContract and OperationContract attributes are used for defining WCF service.           ·   Support security but is less secure as compared to WCF.            ·   Supports security, reliable messaging, transaction and AJAX and REST supports.            ·   Supports XML serializer by using System.Xml.Serialization.            ·   Supports DataContract serializer by using System.Runtime.Serialization.            ·   Supports One-Way and Request-Response service operations.            ·   Supports One-Way, Request-Response and Duplex service operations.          
go to top image