Posts

Interview Q&A

  Configuration-  How to enable auditing for table or columns? What is managed and Unmanaged Solutions?  What are different datatypes in MS CRM? How to change lookup field criteria?  What are different types of views and where they can be used? How to add subgrid on form? and how to change filter criteria of subgrid? What are different types of forms?  How to handle security on forms? If I have 3 main form for table but I can see only 1 form in model driven app? why?  JavaScript -  What are different XRM API's available in CRM? [E] You should know basic syntax and parameter required for each API [E] What is Odata query?  [M] CRM Xrm api's are Synchronous or Asynchronous? If Async then how can we run synchronously?  [C] Different events to trigger JS code in CRM? [E] Should know how data can be retrieved and what we will get for each data type?[E] Should know basic syntax  for lock/unlock, required/ not required, show hide field, sections...

JavaScript WebAPI [Xrm.webApi]

In this blog we will see usecase of Xrm.WebApi. Generally, it is used to do CRUD operation in dynamics CRM. Most of the times we will be using retrievemultiple, retrievesingle and updaterecord.All these web api's are asynchronous, that means once we execute api, it wiill not wait for response. It will execute remaining code till we get response from api. The sample code for webapis can be generated by Dataverse REST Builder tool from xrmtoobox.  We will see below use case of WebApi 1. Xrm.WebApi.retrieveRecord -       To retrieve single record      Parameters - entityname, RecordId, OdataQuery[Select] 2. Xrm.WebApi.retrieveMultipleRecords -      To retrieve the record based on condition      Parameters - entityname, odataQuery [Select, filter] 3. Xrm.WebApi.createRecord -       To create record      Parameters - entityname, data 4. Xrm.WebApi.updateRecord -      To...

JavaScript - Show-Hide/ Lock-Unlock/ Required-NotRequired

JavaScript syntax to show Hide different controls :  function showHide(executionContext) { var formContext = executionContext.getFormContext(); //showHide field formContext.getControl("new_field").setVisible(false); formContext.getControl("new_field").setVisible(true); //showHide tab formContext.ui.tabs.get("tab_tabname").setVisible(false); formContext.ui.tabs.get("tab_tabname").setVisible(true) //showHide section formContext.ui.tabs.get("tab_tabname").sections.get("sectionName").setVisible(false); formContext.ui.tabs.get("tab_tabname").sections.get("sectionName").setVisible(true); //ShowHide related entity from related section var navItem = formContext.ui.navigation.items.get("Courses"); if (navItem) { navItem.setVisible(false); } } JavaScript Syntax to lock-unlock fields - function lockUnlock(executionContext) { var fo...

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...

Most Used Plugin Syntax in Dynamics 365 CRM

Image
We always get requirement which can not be possible using OOB features of CRM and hence we move to the plugin to achieve such requirements. Whenever we need to retrieve field value from plugin, we always check whether field contains value or not by using if else block or ternary operator which makes code lengthy and not readable. In this blog, we will see how to efficiently retrieve field values of different data types. //Single Line Of Text {Defualt Value = null} string businessWebsite = account.GetAttributeValue<string>("new_website"); Console.WriteLine($"Single Line Of text : {businessWebsite}"); //get optionset text string cohort = account.Attributes.Contains("new_type") ? account.FormattedValues["new_type"] : ""; //Optionset {Defualt Value = null} int? customerCohort = account.GetAttributeValue<optionsetvalue>("new_type")?.Value; //currency {Defualt Value = null} int? mostRecentACR = (int?)account.GetAttr...

Get option-set value from text and get option-set text from Value using plugin

Image
In this blog we will discuss the use of StringMap table to get option-set metadata in our CRM plugin. StringMap table holds the metadata information of option-sets. The StringMap table contains the following important columns: "Value": This column stores the string value assigned to each picklist option. "AttributeName": This column contains the logical name of the attribute associated with the picklist values. "AttributeValue": This column stores the numeric value assigned to each picklist option. Numeric value assigned to picklist option is unique. "ObjectTypeCode": Object type code of entity for which attribute belongs. Code snippet to get option-set Value from Text: static int? GetOptionSetValueFromText(IOrganizationService service, string optionSetSchemaName, string optionSetText, int objectTypeCode) { string fetch = @"<fetch> <entity name='stringmap' > <attribute name='value' /> <attribut...