Posts

Showing posts from August, 2023

Most Used JavaScript Syntax used in MS CRM

In this blog we will see how we can retrieve different data types fields values in MS CRM using JavaScript. Different types of data types in MS CRM: Single Line of Text Option Set (Dropdown) Two Options (Radio Button) Image Whole Number Floating Point Number Decimal Number Currency Multiple Lines of Text Date and Time Lookup  Single or Multiline Field :  var name = formContext.getAttribute("new_name").getValue(); formContext.getAttribute("new_name").setValue(); Option-Set Field :  int value = formContext.getAttribute("new_type").getValue(); var optionsetText = formContext.getAttribute("new_type").getText(); formContext.getAttribute("new_type").setValue(100); //100 will be the optionset value Multi-Select Option-Set Field :  var multiselectValueArr = formContext.getAttribute("new_multiselect").getValue(); formContext.getAttribute("new_multiselect").setValue([100, 200, 300]); Two-Option Field :  var value = formConte...

Bulk insert CRM Data into SQL table using sqlbulkcopy

Image
This blog will explain how we can bulk insert any source data [e.g. MS CRM data] into SQL table using C# code. We will follow below steps:  We will create DataTable in C# with same table name and column names of SQL table  Retrieve source data that needs to be retrieved Add retrieved data from source into DataTable Use SQL Connection and sqlBulkCopy to bulk insert source data into SQL First we will create DataTable with same column name available in SQL table For creating DataTable use below syntax: public static DataTable ActionableAudit() { DataTable actionableAudit; // Create a new DataTable. actionableAudit = new DataTable("ActionableAudit"); actionableAudit.Columns.Add(new DataColumn("ChangedOn", typeof(DateTime))); actionableAudit.Columns.Add(new DataColumn("CreatedBy", typeof(string))); actionableAudit.Columns.Add(new DataColumn("CreatedById", typeof(Guid))); return actionableAudit } After creating Dat...