Friday, April 22, 2016

Sharing the Host WiFi with Hype-V image

I use Hyper-V for all of my development work.  Up until now I've been providing internet access to my Hyper-V images by setting up a Virtual Switch in Hyper-V, and configuring it as an Internal network.  When my host is connected to the internet, I use Internet Connection Sharing to this Virtual Switch.  I then configure the Hyper-V images to use a legacy adapter and select this Virtual Switch. Here is how my WiFi adapter is shared.

This procedure is well documented in other posts.  But it has a snag. Internet Connection Sharing insists on using IP addresses in the 192.168.0.* range and your WiFi router must use an alternative IP address range e.g. 192.168.1.* 

I recently upgraded my Virgin broadband and the new router was using the IP range 192.168.0.*  You could supposedly change it but I could not get this to work properly so I started to hunt around for another solution that would leave the IP range unchanged.  I stumbled on the wonderful network bridge.

The solution is the go into Virtual Switch settings and create a new Virtual Switch but select External network. I selected my WiFi network card from the list and enabled "Allow management operating system to share this network adapter".


When you click OK, it takes a minute but what its doing is creating a Network Bridge in your Network Connections along with a  Hyper-V Virtual Ethernet adapter you are probably familiar with.  My virtual machines use the same approach, a legacy adapter that is configured for this external Virtual Switch. 

Now when I look at my Network Connections its a bit odd.  My WiFi adapter displays Enabled, Bridged even when I am not connected to the Internet. When I make the connection in the usual way it is the Hyper-V Virtual adapter that goes through the whole Identifying... stage until it connects.  It looks counter-intuitive but it works a treat.  So that's it. My Hyper-V images are connected to the Internet and I didn't have to change the IP address of the router.


Friday, April 15, 2016

Dynamics CRM 2016 and Use Legacy form rendering

So you may know that Microsoft has improved form load by doing some extensive caching.  There is a setting under General Settings called "Use Legacy form rendering" which you can set to Yes or No.

Now you might wonder why I am writing a post about this setting. Well it was a JavaScript  error on a Form Load that I was getting. I had my own JavaScript code on the Form Load  but the error shown was confusing:
Field:window
Event:onload
Error:Unable to get property '$o_3' of undefined or null reference

Huh? A bit of Googling showed that others had come across it to


The post included this comment "Note that this error only occurs when you turn on the “Use Legacy form rendering”.  Sure enough changing this setting to No avoids the error. 

But what if you want to preserve the faster form rendering?  Patric provide the solution in his blog. 
Add the following line before calling the prefilter function.

Xrm.Page.getControl(“EntityName”)._control && Xrm.Page.getControl(“EntityName”)._control.tryCompleteOnDemandInitialization && Xrm.Page.getControl(“EntityName”)._control.tryCompleteOnDemandInitialization();

Brilliant. 

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.