Posts

Showing posts from 2015

Modify the Columns Shown in The Inline Lookup-CRM 2013 & 2015

Image
How to modify the columns shown in the inline lookup in CRM 2013 Refreshed Entity User Interface and what can be done and what cannot be done. In the example (lookup to Contact), it shows only Name, Company Name, and Email Address. You found that Email Address is not important, you want to show Name, City, and Company Name. Explanation : 1. Go to Form Editor 2. Go to the field and check the lookup that is used, in this case is Contact view (lookup view) and get the Default View of the Lookup field *You can also use custom view as default view. 3. Go to the Contact Lookup View and then you add can re-order the position Previously: Change to: *You cannot modify the Full Name position nor remove it. 4. Test the  Result : * The supported total column shown in the inline lookup is 3 only (including Name as the primary field that is not replaceable) It shows Name, City, and Company Name as per your expectation. 5. You can also use a Composite field, for example, Address Result : And you c

Activate – Deactivate Record using JavaScript in CRM

Activate – Deactivate Record using JavaScript in CRM //Params:entityname,entityGuid,stateCode,StatusCode // Call the funtion changeRecordStatus("contact", Xrm.Page.data.entity.getId(), 1, 2); function changeRecordStatus(EntityLogicalName, RECORD_ID, stateCode, statusCode) {     // create the SetState request     var request = "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">";     request += "<s:Body>";     request += "<Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">";     request += "<request i:type=\"b:SetStateRequest\" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\" xmlns:b=\"http://schemas.microsoft.com/crm/2011/Contracts\">";     request += "<a:Parameters xmlns:c=\"http://schemas.datacontract.org/2004/07/

Using New Scripting Methods in CRM 2016

Image
With the release of Dynamics CRM 2016, new client side methods introduced that we can use to make user experience more interactive while enter data in CRM forms. Following are the methods: • getValue • Keypress • Autocomplete getValue Method – This method is used to get the latest value of the field. Earlier this method was only available in attribute collection, which provides value of the field only after Onchange event fired. Whereas when it is used with control collection, we can capture value as soon as users starts entering value in field, so it means if we have any requirement to validate data entry then we can use this method to make it more interactive. We can use this method like below: Xrm.Page.getControl(field name).getValue(); Let’s take one example that we want to restrict user to enter only number between 0-9 under phone field in account entity, so we can simply use below code to do that: function OnTelephone1KeyPress

Rename and Delete business units

CRM 2011/2013 allows you to rename and delete business units, this can be very useful if you have spelt something incorrectly. To rename a business unitSettings –> Administration –> business /units click on the business unit you want, change the display name and press save You can also delete a business but you must have one business unit. to delete one of the child business units you go to business units Settings –> Administration –> business units click on the business unit you want to delete. First you must disable the business unit by going Actions –> disable you will then be able to delete the business unit

Plug-in stages

Pre validation Registered Plug-in run before the form is validated Useful if you want to implement business logic before the actual validation starts.  i.e., Changes made in plug-in won’t be saved if the validation of the main system plugins complain because the changes are outside the database transaction. Ex – Some “delete” plug-ins. Deletion cascades happen prior to pre-operation, therefore if you need any information about the child records, the delete plugin must be pre-validation. Pre -operation After validation and before the values are saved to the database Post operation Plugin will run after the values have been inserted/changed on the database Example: If and “update” plug-in should update the same record, it is best practice to use the pre-operation stage and modify the properties. That way the plug-in update is done within same DB transaction without needing additional web service update call. Database Transactions in Plug-Ins Plug-ins may

Object-Oriented Programming Fundamentals in C#

Object-Oriented Programming (OOP) Terms Basics Object-Oriented Programming (OOP) : An approach to designing and building applications that are flexible, natural, well-crafted, and testable by focusing on objects that interact cleanly with one another. Class : The code describing a particular entity in the application, such as Customer, Order, or Address. The class contains the code defining the properties and methods (see below). Property : The code defining the data managed by the class, such as CustomerName, OrderNumber, or EmailAddress. Method : The code defining the actions or behaviors of the class, such as Validate or CalculateTotal. Methods are defined in the code with C# functions. Members : Refers to the properties and methods for a class. Object : An instance of a class that is created at runtime. In C#, an instance is created with the  new  keyword. Object Variable : The variable used when creating an object. For example,  var myCustomer = new Customer()

Setting null value using Javascript.in MS CRM

I had an odd error where I was trying to null a lookup field in Javascript in CRM 2013.When the user changed a lookup field, I wanted to blank out a few fields to make them select those fields again.  The fields being nulled were dependant on selection of the first lookup field and the options and values they could pick changed. if (Xrm.Page.getAttribute("field1").getValue() != null) {     Xrm.Page.getAttribute("field1").setValue(null); } if (Xrm.Page.getAttribute("field2").getValue() != null) {     Xrm.Page.getAttribute("field2").setValue(null); } field1 was correctly set to null but field2 refused to be set to null I changed my code to set the required level to none, set field2 to null and then reset the required level to required. //I had to set required level to none because assign null wasn't working, might be fixed in future roll ups     if (Xrm.Page.getAttribute("field1").getValue() != null) {          

The Under Operator in MS CRM 2015

Image
Advanced Find now includes two new operators which work in conjunction with the new hierarchies feature in Dynamics CRM 2015. These operators are called “Under” and “Not Under” and can be used when querying lookup fields in Advanced Find. I have currently set up the Users in our Dynamics CRM system such that the Managerfor each user has been specified. This builds a user hierarchy in the system so we can easily see who reports to who. Let’s assume we have an organisational structure where there are multiple managers at different levels. It would be a tricky in previous versions of Dynamics CRM if I wanted to build a query to show everyone who sat below Bob Jones. In CRM 2015, I can simply use the “Under” operator to find these people. Running this query gives me everyone who sits below Bob Jones, whether they are a direct relationship with that record or not.  

Business Process Flow 2013/2015

CRM 2013 BPF Business process Flows are a new enhancement to dynamics CRM 2013, and they bring the power of guided business rules to the application. Unlike workflow processes, BPFs are designed to work with users and guide them through a variety of business processes. Key Benefits CRM 2013 BPF 1.        BPF allow organization to define the specific steps that need to be taken for something to happen. BPF allow org. to track where in the process the record is. 2.        BPF allow for “stage-gating”, which requires data to be entered before proceedings to the next step. BPF are visually represented on the record. 3.        BPF can be controlled through portable business logic and workflow. An example of this is when a field is hidden via a PBL or a value is populated via a workflow, the BPF incorporates this changes as well. 4.        BPF allow for multiple entities in the BPF(up to five) 5.        There can be 10 active BPF per entity 6.        Users with approp

Set Date Time Field to Now in Plugin Dynamics CRM 2011

Image
In Dynamics CRM 2011 when you are creating or updating records through a plugin, you will sometimes be required to set a date field to the current date and time of the plugins execution. There are two ways of doing this with a plugin. One method is using DateTime.Now, which will give you the local time of the CRM Server. The other method (the recommended method) is using DateTime.UtcNow. This will give you the CRM Server time, but it will be converted into UTC time.   Dynamics CRM 2011 stores all Date/Time fields in UTC time, so by using the ‘DateTime.UtcNow’ approach our dates will be converted into UTC time before hitting the database. When our users read the date through CRM it will be converted back into their local time zone, and will read correctly for them. If we check the database, we can see how the date from the image above is actually stored in the database using UTC time:   If you were to set a date using ‘DateTime.Now’, the exact server time would be saved in

How to convert textbox to hyperlink in MS CRM

function ConvertToLink(fieldName,urlFieldName) {     var itemText = Xrm.Page.getAttribute(fieldName).getValue();     if (itemText != null && itemText != '' && itemText != 'null') {         var url = Xrm.Page.getAttribute(urlFieldName).getValue();         var btn = "<a href='javascript: void(0);' onclick=\"window.open(\'" + url + "\', \'windowname1\');  return false;\" style='color:blue;text-decoration:underline !important'>" + itemText + "</a>";         var ctrl = Xrm.Page.ui.controls.get(fieldName)._control;         // Add the new button         ctrl.get_element().innerHTML += btn;         // Hide the textbox         ctrl.get_element().firstChild.style.display = 'none';     } }

Early Binding and Late Binding In MS CRM 2015

Late Binding In Microsoft Dynamics CRM 2015 and Microsoft Dynamics CRM Online 2015 Update, you can use the Entity class when you work with entities.  When initialized, the Entity class contains the logical name of an entity and a property-bag array of the entity’s attributes.  This lets you use late binding so that you can work with types such as custom entities and custom attributes that weren’t available when your application was compiled.  The key difference between early and late binding involves type conversion. While early binding provides compile-time checking of all types so that no implicit casts occur, late binding checks types only when the object is created or an action is performed on the type.  The Entity class requires types to be explicitly specified to prevent implicit casts. //Get the Value from optionset. int val = ((OptionSetValue)account.Attributes["schemaname"].Value; // Get the Text from OptionSet String optiontext=account.FormattedValue[

When to use Abstract class and what is the benefit of using Abstract class in real time application development.

It is a very common interview question when to use Abstract class and what is the benefit of using Abstract class in real time application development. The common properties of Abstract class are it cannot be initiated, functions and implementation can be partially implemented. Consider an application that calculates salary of full time and contract based employees. There are few common properties of both employees, e.g., both employees have name, address, ID, but different way of calculating salaries. So we can declare one master class named as BaseEmployee and place common properties and Virtual Salary Calculator function with no implementation. Two child classes, FullTimeEmployee and ContractEmployee can inherit from BaseEmployee class and override Salary Calculator virtual function and our problem can be solved, then why Abstract Class should be used? The problem with this inheritance approach is more like logical and business issue, in inheritance we can simply create Ba