Console Application for updating the records

Console Application For Updating the Lead Records :-

Without opening the records in CRM we can update the leads data through console application. For console application we are going with CRMSERVICECLIENT


using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Tooling.Connector; // for connecting the crm service client;
using System.Configuration;  //getting the credentials from app.config file;
using Microsoft.Xrm.Sdk.Query;  // for fetchexpression

App.config file;-
 <add name="CRM" connectionString="AuthType=Office365;Url=https://*****; Username=admin@***; Password=***" />


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Tooling.Connector;
using System.Configuration;
using Microsoft.Xrm.Sdk.Query;

namespace CRM_Console_Application
 class Program
 static void Main(string[] args)
 CrmServiceClient client = new CrmServiceClient(ConfigurationManager.ConnectionStrings["CRM"].ConnectionString);
 IOrganizationService service = client.OrganizationServiceProxy;
 string fetchxml = string.Format(Resource1.String1);
 EntityCollection leads = service.RetrieveMultiple(new FetchExpression(fetchxml));
 foreach (var lead in leads.Entities)
 //Entity leadentity = new Entity("lead");
 lead.Attributes["emailaddress1"] ="";
 lead.Attributes["mobilephone"] = "9059289083";


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s