Showing posts with label JavaScript. Show all posts
Showing posts with label JavaScript. Show all posts

Friday, April 15, 2016

Dynamics CRM 2016 and Legacy Entities

This is not the first time I've run into a problem with so called "Legacy Entities". I am referring to the entities that have been left out in the cold since CRM 2013. These include
  • address
  • opportunity product
  • quote product
  • order product
  • invoice product

There are some things that these entities don't support which include
  • Accessible in the Tablet App
  • Update attributes with workflows
  • Business Rules (though oddly Opportunity product does support business rules)
  • Old style forms

I have also come across with problems when upgrading to CRM 2016. This problem occurred on Opportunity Products form which had been customised in CRM 2015. I removed a number of fields I didn't need and it was working fine. 
After the upgrade to 2016 though I was getting this JavaScript error on form load

Field:window
Event:onload
Error:Unable to get property 'addOnChange' of undefined or null reference

Now that was not from any JavaScript code that I had but from a Microsoft library called OpportunityProduct_main_system_library.js

When I looked into the code I could see that it was referring to attributes that were not on the form:
Manual discount amount
Tax

When I added these back onto the form and hid them, the error went away. 

Moral of the story: Don't delete attributes from legacy forms - just hide them. 

Saturday, December 12, 2015

Dependent (Linked) OptionSets in Dynamics CRM 2015

I recently used the sample code provided in the SDK that allows you to have multiple OptionSets linked together so that selecting an item in the first OptionSet will filter the items appearing in the second. 

https://msdn.microsoft.com/en-us/library/gg594433(v=crm.7).aspx

There was an error in the instructions for configuring the OnLoad event on the form. It says to use

"sample_TicketDependentOptionSetConfig.xml"

 as a parameter.  That's wrong. You need to use 

"sample_TicketDependentOptionSetConfig"

The SDK.DependentOptionSet.init function in the JavaScript file I modified slightly to support multiple languages.  The first few lines now read

//Retrieve the XML Web Resource specified by the parameter passed var clientURL = Xrm.Page.context.getClientUrl();

var userLcid = Xrm.Page.context.getUserLcid();

var pathToWR = clientURL + "/WebResources/" + webResourceName + "_" + userLcid;




The data files were then appended with the relevant LCID for each language 

e.g. "sample_TicketDependentOptionSetConfig_1033.xml"

A very cool and easy to use JavaScript Library. Thanks Microsoft.