Tuesday, September 27, 2016

Trying to update an attribute in Live, which is not allowed : Microsoft Dynamic CRM 2016



Invalid Operation: Trying to update an attribute in Live, which is not allowed

Exception Messages

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Invalid Operation: Trying to update an attribute in Live, which is not allowedDetail:


How and When Problem Occurs

First of all, I am going to make a note that it’s NOT a bug in Microsoft Dynamic CRM.

The exception message flashes when by any mean we try to update any out of the box report in Microsoft Dynamic CRM online.

The reason being Dynamic CRM online does not permit or allow to have an access to SQL Server. All out of the box reports cannot be edited and updated back to dynamic CRM online.

The problem may occurs due to

  • When we try to import a solution, which has any out of the box report.
  • When we try to overwrite any out of the box report, directly from Report edit wizards.


Things to note

Microsoft Dynamic CRM Online only support SSRS (.rdl) with Data source created using fetch data provider. So, in visual studio when selecting report project, we need to select type in data source as


























If you are not getting Microsoft Dynamic CRM Fetch option then you need to install Microsoft Dynamics CRM Report Authoring Extension (with SQL Server Data Tools support).

Download here

Things to know about MS CRM default reports

  • There are 25 out of the box reports which come default with vanilla CRM in an online Microsoft Dynamic CRM 2016 version.
  • There are sub reports also which are part of these report.
  • An example of a Report and a sub report is Campaign Performance. We can list all report by changing the view.









Monday, September 26, 2016

How to hide a section in MS CRM 2016 based on user logged in ?

Today I am blogging about how can we hide a section in MS CRM 2016 using JavaScript.

Where might this functionality be required ?

·         Based on user logged-in, we may not want user to see all details.
·         Based on some selection of check box or some field value, we may require to hide a section altogether.


Understanding MS CRM Page different controls and Hierarchy


The MS CRM Page object is available in forms by referencing Xrm.Page
The Page Object is having two important part.

  • Xrm.Page.data provides methods to work with the form. You can refresh the data in the form and save the form asynchronously.
  • Xrm.Page.ui contains properties and methods to retrieve information about the user interface as well as collections for several subcomponents of the form.


Few of the ui components are :

Xrm.Page.ui.quickForms
A quick view control is a quick view form added to a main form in Microsoft Dynamics CRM that enables you to view information about a related entity record within the main form.

Xrm.Page.ui.tabs         
A tab is a group of sections on a page.

Xrm.Page.ui.process
It provides methods to interact with the business process flow control in a form.

Xrm.Page.ui.navigation
It have items represents one of the available options available in  the navigation bar of an entity.

Xrm.Page.ui.tabs.get("tab_name").sections
A section partition various items of the form within a specific tab. It can be called as a container of all  fields or an attribute of an entity.

For more details about ui component of Microsoft Dynamic CRM, you can refer to MSDN article here
Code to hide a section for a given bunch of CRM users ?


// Obtain the User Id from context of the page.
var userId = window.parent.Xrm.Page.context.getUserId();

// Check for user Id match
if (userId == "{3220927E-0205-DD11-93BA-0018FE304530}"     // User – Vipin Jaiswal
   || userId == "{C6928F30-8B5A-E611-80EE-00155DCFC14C}"   // User – Heena Gupta
   || userId == "{74EFA877-0205-DD11-93BA-0018FE304530}"   // User – Pradnya Apte
   || userId == "{5744B501-74F2-E311-BFDF-000C295A41AA}"   // User – Mohan Sony
   )
{           
// Use setVisible(true) to DISPLAY section
Xrm.Page.ui.tabs.get("tab_name").sections.get("section_name").setVisible(true);
}
else
{
// Use setVisible(false) to HIDE section
Xrm.Page.ui.tabs.get("tab_name").sections.get("section_name").setVisible(false);
}


Note :
How to obtain Guid of User

Just open a CRM User record in new tab of browser and from the url take out the guid.

An Example

etc=8&extraqs=&histKey=68878144&id=%7b3220927E-0205-DD11-93BA-0018FE304530%7d
&newWindow=true&pagetype=entityrecord&sitemappath=Settings%7cSystem_Setting%7cnav_security

Within %7b ---  and %7d in url, unique guid is referred internally for CRM reference.


How to obtain section and tab name used in code above

Open the form in edit mode and select any tab or section and click on its properties.