Archive

Posts Tagged ‘CRM 2011’

Undefined Error – Activity Feeds CRM 2011

November 5, 2013 Leave a comment

You might have experienced the below script error, when you click on ‘What’s New’ link on Sitemap

Activity Feeds - Script error

Activity Feeds – Script error

To fix this error, check if the logged in user has “Activity Feeds” security role or not.

Activity Feeds Security Role

Activity Feeds Security Role

 

“Activity Feeds” security roles comes, when you import the “Activity Feeds” managed solution in to your CRM application.

Every user other than ‘System Administrator’ should have “Activity Feeds” security role to view feeds.

Plug-in on related entities during ‘Cascade All’ actions

Assume the relationship behavior between ‘Contact’ and ‘Appointment’ is “Cascade All” on ‘Assign’ action.

Relationship Behavior

Relationship Behavior – Assign – Cascade All

By virtue of that, if a Contact has 2 Appointments, if I change the owner of ‘Contact’ the related 2 Appointment owner also changes.

In one of the requirement, we have to restrict the Cascade operation based on business logic on child record (i.e.,  Appointment)

So I registered a Plugin on ‘Assign’ of ‘Appointment’ and want to handle the Cascade operation, but the Plugin never get executed.

Reason & Solution

  • CRM treats Cascade Assign operation on Child records as an Update.
  • Register the Plug-in on ‘Update’ instead of ‘Assign’ message.
  • In the Update plug-in, the Target entity only contain ‘Owner’ field

🙂

Multiple forms of type Main are found. No Record Walls are added – CRM 2011 Activity Feeds Error

August 28, 2013 2 comments

I was getting below warning message, when I tried to configure Activity Feeds for entity ‘Contact’ and selected the “Enable walls for this type of record form” check box

Multiple forms of type Main are found. No Record Walls are added. Configure the walls to the required forms manually

Activity Feeds Configuration

Activity Feeds Configuration

Reason

The reason was, my ‘Contact’ entity has multiple forms of type “Main” configured and CRM does not allow us to check  “Enable walls for this type of record form” check box.

Contact Entity Multiple Forms

Contact Entity Multiple Forms

So to configure the walls for ‘Contact’ entity, we have to do it manually by following below steps

How to configure “Record Wall” to required forms manually

To configure wall manually

  • Choose the form you need to show the record wall for among multiple forms
  • Open the Form Editor
    • Insert a new Tab with single column (Go to Insert > Tab > One Column)
    • Open the Tab to edit (Go to Tab Properties > Display)
      • Name= tab_recordwall
      • Label = Record Wall
      • Uncheck “Expand this tab by default”
    • Tab Properties > Events
      • Form Libraries, add “msdyn_/ActivityFeeds.Form.js” file
      • In event handlers, Add
        • Library: msdyn_/ActivityFeeds.Form.js
        • Function: ActivityFeeds.Form.CustomizationUtils.updateRecordWallRenderingState
        • Check “Enabled.
        • Check “Pass execution context as first parameter”
Tab Properties

Tab Properties

 
  • Save your changes to the tab and return to the form editor.
  • Select the section inside of the “Record Wall Tab”.
  • In the Form Editor, Add ‘RecodWall.htm’ file by click Insert > Web Resource
  • In the “Record Wall” Tab’s ‘Section’, choose ‘General’ tab and set
    • Web resource = msdyn_/RecordWall.htm
    • Name = RecordWall
    • Visible by Defualt = checked
    • Pass record object…= checked
Record Wall Tab's Section Properties

Record Wall Tab’s Section Properties

  • In the “Record Wall” Tab’s ‘Section’, choose ‘Formatting’ tab and set
    • Layout > One column
    • Row Layout > 15 rows (this is flexible, but 15 is standard the standard look).
    • Display border = yes
    • Scrolling = as necessary
  • Save & publish

🙂

Xrm.Utility is undefined error – CRM 2011

Other day when I deployed my solution on a new CRM server, I was getting “Xrm.Utility is undefined” script error.

I refered“Xrm.Utility” JScriptin my code to open forms which was causing script issue.

Reason & Fix

  • The CRM server is not having UR 8
  • Since Xrm.Utility object was added in CRM 2011 Update Rollup 8, installing UR 8 on server solved the issue

🙂

Merging solutions in CRM 2011

July 17, 2013 2 comments

Imagine you have 2 developers (Dev 1 & Dev 2) in your team working on 2 different organizations and 2 solutions, at the time of every release, you need to merge the components of both developers in to 1 solution.

One way is

  • Import Dev 1 & Dev 2 solutions in to another new organization.
  • Create a new solution and add the components of both solutions manually
  • This is easy if Dev 1 & Dev 2 solutions has less components.

What if the components are huge? you need to manually pick and add components both solutions in to a single solution or

Another way of merging solutions

  • Export & Save the both Dev 1 & Dev 2 solutions
  • Extract the saved solution .zip folders
  • Open “Solution.xml” files in both solutions in a notepad
Solution components

Solution components

  • In the <UniqueName> node, provide same unique name in both “Solution.xml” files
SolutionXml file

SolutionXml file

  • Import them back to new a organization
  • After the import, we get a new merged solution.
  • This is easier way of merging if the solutions has lot of components

Refer below MSDN video for more details

🙂

Categories: CRM 2011 Tags: , ,

event.returnValue is not working after UR 12 – Fix

July 15, 2013 2 comments

We use event.returnValue=false statement, to stop the event execution. (i.e., I can stop my crm form’s save action, if I write event.returnValue=false statement on my onsave() event).

After I upgraded to UR12, I was getting script error, if I use the event.returnValue statement.

Reason

  • Update Rollup 12 and December 2012 Service Update support additional browsers by generating HTML that supports W3C standards.
  • This requires removing dependencies on HTML components (HTC) that are specific to Internet Explorer.
  • Hence event.returnValue statement has been deprecated

Fix

  • Use context.getEventArgs().preventDefault() function to cancel the event execution

How do I use this

  • First to get “context”, enable the OnSave event handler to pass the execution context as the first parameter to the OnSave event handler.
  • Open customization form -> Form Properties and in “Handler Properties” window, select the “Pass execution ….” checkbox
  • Pass execution context

    Pass execution context

  • Next in your Jscript , read the context as first parameter

function onsave(context) {

// Prevent the event execution

context.getEventArgs().preventDefault();

}

Get more details on latest CRM JScript changes from this link

🙂

CRM online instance opening only in Mobile version – Fix

July 10, 2013 2 comments

The other day, when I upgraded to IE 11 browser and when I browse my CRM online URL, I was getting only mobile version (i.e., http:// Orgname.crm5.dynamics.com/m/default.aspx).

CRM Mobile Version

CRM Mobile Version

Even if i explicitly provide the URL http:// Orgname.crm5.dynamics.com/default.aspx, it was redirecting to Mobile version Reason

  • CRM online is not compatible with IE 11

Fix

  • Add CRM online site to IE 11 compatibility list
  • Go to Tools -> Compatibility View Settings
  • Add the “dynamics.com” website to compatibility view settings by click on “Add”
Comaptibility Settings

Compatibility Settings

  • If its “OnPremise” add CRM server name to compatibility view settings.
  • Refresh the browser

🙂

Retrieve records with Fetchxml using Jscript – CRM 2011

June 20, 2013 1 comment

Retrieve the records using FetchXML is a convenient way as we can form the FetchXML easily using the ‘Advanced Find’ .

Download Fetch XML

Download Fetch XML

Once you have the FetchXML ready, below is the JScript to execute and read the result set.

  • In this sample, I am fetching records from custom entity “Bikes” which has relationship with ‘Contact’ entity. (i.e., Fetch all the bikes of a Contact whose full name contains ‘Raj’)
  • Note – I am using “xrmservicetoolkit” helper Jscript which is available in CodePlex. You just need to download the Jscript and refer to your CRM form.

function getBikesByContactName() {

var fetchXml =

“<fetch mapping=’logical’>” +

“<entity name=’raj_bike’>” +

“<attribute name=’raj_name’ />” +

“<attribute name=’createdon’ />” +

“<link-entity name=’contact’ from=’contactid’ to=’raj_customerid’ alias=’ad‘>” +

“<attribute name=’fullname’ />” +

“<filter type=’and’>” +

“<condition attribute=’fullname’ operator=’like’ value=’%raj%’ />” +

“</filter>” +

“</link-entity>” +

“</entity>” +

“</fetch>”;

// Execute the fetch

var bikes = XrmServiceToolkit.Soap.Fetch(fetchXml);

// Get the results by loop through ‘bikes’

for (var indxBikes = 0; indxBikes < bikes.length; indxBikes++) {

alert(“Bike Name – “+bikes[indxBikes].attributes.raj_name.value);

alert(“Created On – “+bikes[indxBikes].attributes.createdon.value);

// Get the related entity (i.e., Contact) attributes using LinkEntity alias)

alert(“Related entity attribute (Contact Name) – ” + bikes[indxBikes].attributes.ad.fullname.value);

}

}

🙂

Filtering Lookup view based on custom logic CRM 2011

June 17, 2013 1 comment

In one of my requirement, I have to filter my lookup view results based on another lookup field value.

I have 2 Lookup fields on my form

  • Product
  • Product Category

When I click on “Product” lookup, I have to show only Products with category as “Product Category” field value.

Filter Lookup View

Filter Lookup View

We can achieve this requirement using Jscript by following below steps

  • Create a new view with our filter
  • Use the SDK method addCustomView, to add newly created view for the lookup dialog box
  • Set this view as default view
  • Disable the view selector to avoid user to select other views from Lookup dialog
  • Put above logic in a function register it on “onchange” event of “Product Category” field

Below is the Jscript function

function createAndSetLookupView() {

// Some GUID but only needs to be unique among the other available views for the lookup

var viewId = “{CB6F8184-D7C2-4664-9FAB-18FD9DCDB22A}”;

// Name of the view

var viewDisplayName = “My filtered view”;

// Prepare the xml with columns to display and filter

// Tip : Use Advanced Find to prepare th FetchXML

var fetchXml = “<fetch version=’1.0′ ” +

“output-format=’xml-platform’ ” +

“mapping=’logical’>” +

“<entity name=’new_product’>” +

“<attribute name=’new_productid’ />” +

“<attribute name=’new_name’ />” +

“<attribute name=’new_categoryid’ />” +

“<attribute name=’createdon’ />” +

“<order attribute=’new_name’ ” +

“descending=’false’ />” +

“<filter type=’and’>” +

“<condition attribute=’new_categoryid’ ” +

“operator=’eq’ ” +

“uiname='” + {categoryName} + “‘ ” +

“uitype=’new_category’ ” +

“value='” + {categoryGUID} + “‘ />” +

“</filter>” +

“</entity>” +

“</fetch>”;

var layoutXml = “<grid name=’resultset’ ” +

“object=’1′ ” +

“jump=’new_name’ ” +

“select=’1′ ” +

“icon=’1′ ” +

“preview=’2′>” +

“<row name=’result’ ” +

“id=’new_productid’>” +

“<cell name=’new_name’ ” +

“width=’150′ />” +

“<cell name=’new_categoryid’ ” +

“width=’150′ />” +

“<cell name=’createdon’ ” +

“width=’100′ />” +

“</row>” +

“</grid>”;

try {

// Lookup field which you want to add new view

var lookupControl = Xrm.Page.ui.controls.get(“new_productid”);

// Add the created view to Product lookup and set this view as default

lookupControl.addCustomView(viewId, “new_product”, viewDisplayName, fetchXml, layoutXml, true);

//Disable “View Selection” dropdown of “Product” lookup dialog

document.getElementById(“new_productid”).setAttribute(“disableViewPicker”, “1”);

}

catch (e) {

alert(“Error in createAndSetLookupView() – ” + e.description);

}

}

🙂

Retrieve associated records (N:N related)

In CRM, If you create N:N relationship between 2 entities, it creates an intermediate entity (i.e., Relationship Entity) with 3 fields

  • Primary key field of “Relationship Entity”
  • Entity 1 Primary Key field
  • Entity 2 Primary Key field
N toN Relationship

N to N Relationship

In this sample, I have 2 custom entities “Bike” and “Bond” with N:N association. (i.e., A ‘Bike’ can have N no of ‘Bonds’ and a ‘Bond’ can be associate with N ‘Bikes’)

To get all the ‘Bonds’ of ‘Bike’ with name “Honda”, below is the query expression.

string entity1 = “raj_bike”;

string entity2 = “raj_bond”;

string relationshipEntityName = “raj_bike_bond”;

QueryExpression query = new QueryExpression(entity1);

query.ColumnSet = new ColumnSet(true);

LinkEntity linkEntity1 = new LinkEntity(entity1, relationshipEntityName, “raj_bikeid”, “{Entity 1 Primary key field (i.e.,raj_bikeid)}“, JoinOperator.Inner);

LinkEntity linkEntity2 = new LinkEntity(relationshipEntityName, entity2, “raj_bondid”, “{Entity 2 Primary key field (i.e.,raj_bondid)}“, JoinOperator.Inner);

linkEntity1.LinkEntities.Add(linkEntity2);

query.LinkEntities.Add(linkEntity1);

// Add condition to match the Bike name with “Honda”

linkEntity2.LinkCriteria = new FilterExpression();

linkEntity2.LinkCriteria.AddCondition(new ConditionExpression(“raj_bikename”, ConditionOperator.Equal, “Honda”));

EntityCollection collRecords = service.RetrieveMultiple(query);

Note : To retrieve columns from Entity 2, set ‘Alias’ to ‘LinkEntity2’.

🙂