Archive

Posts Tagged ‘CRM 2011’

CRM 2011 (on-premise) – Querying Filtered views from CRM DB

We recently working on Data migration from CRM 2011 on-premise to Dynamics 365.

We got the CRM 2011 SQL DB back up, which we restored in our SQL server. But when we run query on ‘Filtered’ views we were getting 0 results.

FilteredView_1

Reason:

  • FilteredViews always run on CRM User context
  • The account I logged in to SQL server is not a CRM User/Service Account and hence Filteredview returning 0 results

Fix:

  • Before you querying ‘Filtered’ view, set the Context to CRM User using GUID
  • Below is the syntax:

— Set the Context

DECLARE @userid uniqueidentifier;
SET @userid = convert(uniqueidentifier, ‘123A81A3-89C3-E411-B6EF-441EA155CAB5’);
SET CONTEXT_INFO @userid;

–Execute the query
Select top 10 name,statecode,statecodename from FilteredAccount (nolock)

  • GUID used in above query is the valid CRM user’s GUID.
  • Now we should get the Accounts based on the Privilege and Access level of the User GUID we set the context with.

FilteredView_2

Advertisement

Site map changes after Activity Feeds solution import

In our CRM application we removed ‘Sales’ tab as per a business requirement.

 

Later as part of another requirement we installed ‘Activity Feeds’ managed solution in our application.

 

To our surprise ‘Sales’ tab resurfaced only with “What’s New” link.

Activity Feeds - Sitemap changes

Activity Feeds – Sitemap changes

Fix

To remove ‘Sales’ tab we followed below steps

  • Extract ‘Activity Feeds.zip’ managed solution folder
  • Open ‘Customizations.xml’ file
  • Removed ‘Sales’ sub area xml node and Save ‘Customizations.xml’ file
  • Zip the files and reimport the solution
  • It should remove ‘Sales’ tab

Note – You can include “What’s New” link on Workplace or other tabs required as per your business requirement.

🙂

Get the view name of main grid using JScript

January 29, 2014 Leave a comment

We got a requirement to Enable\disable ribbon button based on selected view.

View name

View name

We used JScript to disable the button by getting the selected view name.

Below is the script to get the selected view name of  Main Grid

var viewName = “”;

if (crmGrid && crmGrid.control) {

viewName = crmGrid.control.get_viewTitle();

}

🙂

Categories: CRM, JScript Tags: , ,

Disabling Activities rollup view option using Jscript

January 23, 2014 Leave a comment

In CRM, when you choose ‘Related “Regarding” Records’ option from ‘Activities’ left navigation of Account form, It loads Activities rollup view.

Activities Rollup view option

Activities Rollup view option

Recently we got a requirement to disable rollup option.

So we used below script to remove the ‘Related “Regarding” Records’ option from “Include” dropdown.

document.getElementById(“navActivities”).onclick = function () {

Mscrm.Details.loadArea(this, “areaActivities”);

document.getElementById(“areaActivitiesFrame”).onreadystatechange = function () {

if (this.readyState == “complete”) {

var doc = this.contentWindow.document;

var filterOn = doc.getElementById(“crmGrid_Account_ActivityPointers_ViewControl”);

filterOn.value = “ImmediateRelatedView”;

filterOn.options.remove(1);

// Refresh the grid

var evt = document.createEvent(“HTMLEvents”);

evt.initEvent(“change”, false, true);

filterOn.dispatchEvent(evt);

}

};

};

How do I use the script

  • Put the above script on form’s onload event
  • After the execution of script form looks as below
Hide 'Related Records'

Hide ‘Related Records’

What  are we doing in script

  • Get the Activities IFrame id (i.e., areaActivitiesFrame)
  • When the IFrame load completes (i.e., readyState == “complete”)
    • Get the “Include” dropdown control (i.e., ‘crmGrid_Account_ActivityPointers_ViewControl’)
    • Remove the ‘Related “Regarding” Records’  option

Note – The above script is unsupported which is not recommended and works for pre & post UR 12

Table alias is not unique amongst all top-level table and join aliases – Exception

December 18, 2013 2 comments

Recently we upgraded from UR 8 to UR 13 and from then I was getting ‘Unexpected’ error when I was adding members to my ‘Dynamic Marketing list’ using ‘Advanced Find’ window.

Below is the error log from my Event viewer

Exception type: CrmException

Exception message: Table alias a_7f4fc1baff99e111bef200155dc87c59 is not unique amongst all top-level table and join aliases

This is a known issue  with UR 12 and would be resolved in UR 15.

Here is the link which has solution/workaround for the issue.

🙂

Free CRM online book by Power Objects

December 6, 2013 Leave a comment

Power Objects has come up with a free online CRM book.

The content of this book covers below topics

The best part is, this book will be updated as the CRM software changes.

Check this out @ CRM Book

🙂

Categories: CRM Tags: , ,

Why ‘RetrieveMultiple’ plug-in not firing when I choose ‘Activities’ roll-up view

November 26, 2013 Leave a comment

I had a plug-in registered  on ‘Activities’ (i.e., ActivityPointer) on ‘RetrieveMultiple’ message.

The Plug-in getting triggered when I open ‘Activities’ from any where (i.e., From ‘Advanced Find’, Sitemap on workplace area, Associated views of  all custom entities) except when I open an account and click on ‘Activities’ associated/roll-up view.

Reason

  • For ‘Accounts’, CRM out of the box provides a rollup view for activities. When you click on ‘Activities’ associated view, CRM uses ‘Rollup’ message instead of ‘RetrieveMultiple’.
Activities Rollup View

Activities Rollup View

  • This is the reason why the ‘Retrieve Multiple’ plug-in is getting ignored when you click on ‘Activities’ link.

Workaround

  • To fire a plug-in when user clicks on ‘Activities’ link from ‘Account’, we need to register a Plug-in on ‘Rollup’ message.
  • However ‘Rollup’ message will not be exposed by CRM (Refer below Plug-in registration tool screen). It needs DB level tweaking to get the message and register a Plug-in which is strictly UN-SUPPORTED
Roll up message unavailable

Roll up message unavailable

  • Refer article how to do it unsupported way.

🙂

Found more than one RibbonDiff entity – Error while publishing customizations

November 24, 2013 3 comments

Other day when I was trying to edit my ‘Account’ entity ribbon using ‘Ribbon Work Bench’ tool, I was getting ‘Found more than one RibbonDiff entity’ error at the time of publishing customization’s.

Refer the KB Article

Reason

  • One of the reason could be, In <RibbonDiffXml>  there might be more than one  element with same ‘Id’.
  • In my case, I had two <HideCustomAction> node with same ‘HideActionId’

Fix

To fix the issue I followed below steps

  • Create a solution with the affected entity and export
  • Extract the folder, open the “customizations.xml”
  • Go to <RibbonDiffXml> and check if any of the XML elements with same Id’s
  • Delete or Rename the duplicate XML elements
  • Save, Re-import and Publish the solution

Note –

If by following the above steps in ‘Fix’ does not solve the problem, try these steps

  • Take a backup of “customizations.xml” file
  • Now open the original ‘customizations.xml’ and clear the xmlelements in <RibbonDiffXml> section
  • Save, Re-import and Publish the solution

Now if you open crm application and open the entity, you don’t find old ribbon changes since we clear all xml elements in <RibbonDiffXml> section.

To get back old changes and fix the issue follow these final steps

  • Export the solution back
  • Open “customizations.xml” file and copy the <RibbonDiffXml> section file from backup file
  • Make sure you don’t have any elements with duplicate Id’s
  • Save, Re-import and Publish the solution

🙂

Show custom messages as banner notifications – CRM 2011

November 17, 2013 Leave a comment

In CRM 2011, one way to show custom messages is using Jscript ‘alert’ function.

In one of our requirement we have to display a custom message on CRM form banner like OOB notification.

Notification

Notification

We can achieve this using Jscript, but it’s an unsupported way and there are no guarantees that this code won’t change in the future.

I am providing 2 scripts which is compatible Pre and Post UR 12.

Post UR 12

// Level – 1 (Critical), Level – 2 (Info), Level – 3 (Warning),

function addNotification(message, level) {

try {

var notificationsList = Sys.Application.findComponent(‘crmNotifications’);

if (notificationsList) {

notificationsList.AddNotification(‘noteId1’, level, ‘namespace’, message);

}

} catch (e) {

}

}

Pre UR 12

// Level – 1 (Critical), Level – 2 (Info), Level – 3 (Warning),

function addNotification(message, level) {

try {

var notificationsArea = document.getElementById(‘crmNotifications’);

if (notificationsArea) {

if (level == 1) { //critical

notificationsArea.AddNotification(‘mep1’, 1, ‘source’, message);

}

if (level == 2) { //Info

notificationsArea.AddNotification(‘mep3’, 3, ‘source’, message);

}

if (level == 3) { //Warning

notificationsArea.AddNotification(‘mep2’, 2, ‘source’, message);

}

if (message == “”) { // Clear the notifications

notificationsArea.SetNotifications(null, null);

}

}

} catch (e) {

}

}

How do I use the method

  • To show custom message as Information, pass message and Level =2

              addNotification(“This is sample message.”, 2);

Note – CRM 2013, has a new feature to display  Notifications which is a supported way.

🙂

‘Selected record types not defined for connection roles’ – Error

November 12, 2013 Leave a comment

In CRM, ‘Connections’ are relationships between two entity records in the system.  It’s a way to create a relationship (link) between two entities records.

I got the below error when I try to connect one of my custom entity record with ‘Account’ by the role ‘Referred by’

Connection Role - Error

Connection Role – Error

Fix

We have to configure the entity type on the “Connection Role”, Referred by

  • Go to ‘Advanced Find’ –> Connection Role
  • Open the ‘Connection Role’, ‘Referred By’
  • Choose the entity you want this ‘Connection Role’ work for
Connection Role - Record Types

Connection Role – Record Types

  • Save and Close

🙂