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.


I have created some Generic Method to Hide and Show Tab and Section

Please refer here : 

https://vjcity.blogspot.com/2021/07/generic-method-to-hide-and-show-tab-and.html

 

 


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.

Guidelines to write good JavaScript code in Microsoft Dynamic CRM

https://vjcity.blogspot.com/2019/08/guidelines-to-write-good-javascript.html


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 the new tab of the 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.























Friday, September 16, 2016

Email Templates filtering for MS CRM Users based on Country


Hello Guys,

One of my client was facing an issue in which CRM user were getting trouble choosing a template when replying to customer.

Problem Statement

Let's take an example to understand the problem statement in a better way.

Assume an organization operates globally in Canada / LATAM / US / India.
CRM Users (the CSR's) have to resolve the case's of a customer's and in reply were suppose to use predefined template configured in CRM.

The problem customer representative (CSR's) facing is they are viewing all templates in the system and its becoming difficult for them to choose the correct template.

The number of templates also getting increased as everyone in the system is creating his / her own templates.


Solution Approach

1) We need to implement business unit for each country and allocate user under respective business unit in CRM.

2) We need to modify security role so that user can have an access to business unit level access on email template.

In this way, we would be managing templates country specific and CSR's won't find it cumbersome to choose the correct templates.


Steps to configure Business unit and security role 

1)      Create or modify a Role with Business-Unit level access for an Email Template.





























     

2)      You need to change the user business Unit depending upon which country he / she belongs to. If you open a user records, you will find changing business unit option as shown in below image.


3)      Once a business unit is changed, we need to manage roles for a user’s. 
      Give user a role which is having template access level equal to business unit level. (as in Step 1)

a.       Click on Manage Role on user record.




b.      Select on role created as depicted in below image.



 


That’s it.

Now when user may be selecting templates or when responding to case as in activity. 
Only email templates which belongs to their business unit will appear.


Thanks.
Vipin Jaiswal





Microsoft Dynamic CRM SQL Server timeout expired


Most of us may have come across SQL timeout expired error while doing some operation in Microsoft Dynamic CRM.


















Resolution

The solution which I am proposing is only applicable to On-Premise and ADFS type of Dynamic CRM installations.

We need to increase the timeout in Registry configuration of windows where dynamic CRM is installed. 


The path to add registry sub key:

HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ MSCRM


There are two DWORD that need to be created.


DWORD 
Value (in Decimal)
OLEDBTimeout
86400
ExtendedTimeout
2147483647


Please Note

OLEDBTimeout
  • The recommended value of this is between 30 and 300. 
  • The value of 86400 is equivalent to 24 hours.


ExtendedTimeout
  • Value, can be larger than 1,000,000.
  • However, do not type a value that is larger than 2,147,483,647. This is hexadecimal 0x7FFFFFFF.


This should only be done temporarily or as a troubleshooting step.
Leaving this setting too high can result in performance issues.

After adding the DWORD it should look something like this.















MSDN provide a detail understanding of SQL time-out.
https://support.microsoft.com/en-us/kb/918609


There are other Timeouts in Microsoft Dynamic CRM.
http://www.powerobjects.com/2013/06/28/timeouts-in-microsoft-dynamics-crm-2011/

I hope this will help us avoiding Time out error in SQL.

Thanks.




Thursday, September 15, 2016

How to create a custom Lookup control to be used in web resource in Microsoft Dynamic CRM (MS CRM)?



Requirement 

I was working for one report requirement, which require to filter out records based on Account (Customer).

Let’s assume, if we want to list all opportunities based on account selected.

The first question comes to my mind was, can I use look up control of dynamic CRM as a control directly in my custom report (web-resource) ?

The answer is ‘Yes’, with a little bit of scripting and CSS, we can create our own look up control and invoke Dynamic CRM Look Up Dialog box.

Guidelines to write good JavaScript code in Microsoft Dynamic CRM

https://vjcity.blogspot.com/2019/08/guidelines-to-write-good-javascript.html


Outcome as in images below












Solution with step by step approach

1)      We need to make reference to JQuery and ClientGlobalContext.js.aspx files in our solution.

<script type="text/javascript" src="ClientGlobalContext.js.aspx"></script>
<script src="https://test.crm4.dynamics.com//WebResources/vj_jquery.min"></script> 

2)      The JavaScript method which are used to invoke lookup dialog box of dynamic CRM.

function OpenLookup(objecttypecode)
{
   var serverurl = "https://test.crm4.dynamics.com";
   var DialogOptions = new Xrm.DialogOptions();
   DialogOptions.width = 800;
   DialogOptions.height = 600;

   var url = serverurl + "/_controls/lookup/lookupsingle.aspx?class=null&objecttypes=" + objecttypecode + "&browse=0&ShowNewButton=0&ShowPropButton=1&DefaultType=0";

   Xrm.Internal.openDialog(url, DialogOptions, null, null, CallbackFunction);
}

function CallbackFunction(event)
{
   var name = event.items[0].name;
   var id = event.items[0].id;
   $('#txt_lookup_name')[0].value = name;
   $('#txt_lookup_id')[0].value = id;
}

Objecttypecode parameter of method OpenLookup, represent internal value for an entity. 

For an example.
Entity
Object Type Code
account
1
contact
2
opportunity
3

You can further refer to various entity type and its internal object type code here


3)      A small bit of CSS for making it look like CRM Look Up control.

    <style>
        .enjoy-css {
            display: block;
            float: left;
            padding:2px 5px;
            border: 1px solid #b7b7b7;
            font: normal 12px/normal segoe ui;
        }
        .lookupImg {
            display: block;
            float: left;
            padding-top:2px;
            border: 1px solid #b7b7b7;
        }
        .lookupAlignment {
            text-align:left;
            vertical-align:middle;
        }
        span {
            font: normal 16px/normal segoe ui;
        }
        td {
            font: normal 14px/normal segoe ui; width:200px;
        }
    </style>

4)      HTML Code for rendering control and invoking JavaScript methods.

OpenLookup – method is highlighted in below code and ‘1’ is passed to open lookup control for account entity.

<body>
    <br />
    <span>
        Custom Lookup Control by - Vipin Jaiswal ( <u>vipinjaiswal12@gmail.com</u> )
    </span>

    <br /><br /><br /><br />
    <table>
        <tr>
            <td>Account </td>
            <td class="lookupAlignment">
                <input type="text" id="txt_lookup_name" class="enjoy-css" />
                <img id="img_lookup_search" src="https://test.crm4.dynamics.com//WebResources/vj_search_normal.gif"
                    onclick="OpenLookup('1')"
                    class="lookupImg" />

            </td>
        </tr>
        <tr>
            <td>Selected Account Guid
            </td>
            <td>
                <input type="text" id="txt_lookup_id" class="enjoy-css" />
            </td> 
        </tr> 
    </table>
    <br />   
</body>



5)      An Image which represent search Icon





Here I am updating this article further, just to inform that we would be getting all values of the Selected view from CRM Dialog box.


We can get other values of the view as well from the dialog box.
In above article, we JavaScript method – function CallbackFunction(event)
In the parameter event, we are getting all the values of selected view.

I put a debugger to check, values.




And here are the values in the JSon format. 

[{"name":"name","value":"XX"},
{"name":"telephone1","value":"+917974058950"},
{"name":"address1_city","value":"Bhopal"},
{"name":"primarycontactid","value":"Test Contact"},{"name":"accountprimarycontactidcontactcontactid.emailaddress1","value":"vipinjaiswal12@gmail.com"},
{"name":"processid","value":""},
{"name":"processts","value":""}]

I hope you find this article interesting.

Thanks.

vipinjaiswal12@gmail.com