Microsoft Dynamics CRM 4 custom entity form onload event not firing - dynamics-crm

We have a problem with the onload event of the form for a custom entity not firing. The form did work correctly for a period but recently has stopped working. Now none of the code in the event is executed when the form is opened - either when creating a new instance of the entity or when opening an existing one. The code does however get executed when the form is previewed.
For testing purposes the original code has been removed and the onload event currently only has the following:
crmForm.all.ownerid_c.style.display = 'none';
crmForm.all.ownerid_d.style.display = 'none';
alert("OnLoad event fired");
In preview the Owner attribute is hidden and the alert is shown. When running the form normally the attribute is not hidden and there is no alert (there are also no Java errors reported).
The full CRM version is 4.0.7333.1219. The entity was originally created on a different CRM installation which was initially version 3. That environment was upgraded to version 4 before we did the export – import process for migrating it to the current environment. The form worked correctly for a period of time on the new environment but at some stage stopped doing so.

I enabled platform tracing using Microsoft Crm Diagnostics Tool 4 and now the onload event is executed. It still works when tracing is disabled again.
God I love developing in this environment.

Related

CRM 365 - Managed solution import does not remove event handlers

A form in our UAT environment contains falsely 2 event handlers on a field.
I have created a solution in DEV environment, in which I included the same form, which only has 1 event handler on the specific field.
When I imported the solution in UAT, the field continued to have 2 event handlers on it.
I tried both updating and upgrading the solution in UAT, but the field still has 2 event handlers.
I do not want to update the UAT environment in the default solution, and create an unmanaged layer in order to fix the issue.
What should I do?
The most common reason is that you have some unmanaged solution layer(s) on your form, you can check and delete it, more detail here

Dynamics 365: Microsoft Dynamics CRM has experienced an error System.Runtime.Serialization.SerializationException

I created a new custom activity in an existing assembly, it retrieves a record from an entity and copies that record again in the database with some little changes,
then I'm calling this custom activity in a workflow "after completing a task" it works normally and created the new record I wanted to be created, but when completing a different task using a different custom activity in the same assembly it throws the below error.
I tried to unregister the new custom activity and remove its calling from the workflow it throws the same error although the newly added activity is unregistered!!
error:
[Microsoft.Crm.ObjectModel: Microsoft.Crm.Extensibility.InternalOperationPlugin]
[46f6cf4c-14ae-4f1e-98a1-eae99a37e95c: ExecuteWorkflowWithInputArguments]
Sync workflow 'Tedata | Service Order | Technical Decision Taken' terminated with error 'System.Runtime.Serialization.SerializationException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #93D57568'
</s:Fault></s:Body></s:Envelope>
Note: the activity inside this workflow ( 'Tedata | Service Order | Technical Decision Taken) is already existing and I didn't change it.
the reason is I was registering the custom activity with isolation mode sandbox and one of the custom activity in the assembly using early bound.
so to avoid this error, I changed the code to be late-bound, Workflow started working fine in Sandbox mode as well or register the workflow to be isolation mode none

Problems with SELECTION_CHANGED_ EVENT in Forge Viewer v7*

I have a problem when I upgraded Forge Viewer from v6* to v7* with SELECTION_CHANGED_ EVENT, everything is working fine if I select the object from the Viewer, but when I select the object from the Model Browser the getSelection method returns empty.
This works fine in the v6* but not in v7*.
The model browser behavior has changed in v7. You'll notice that clicking an object in the model browser now isolates it instead of selecting it. So, for your original use case, consider listening to the Autodesk.Viewing.ISOLATE_EVENT event, or to the Autodesk.Viewing.AGGREGATE_ISOLATION_CHANGED_EVENT event.

Angular 2 events get postponed strangely when I include some other non-angular script

I have encountered a strange problem when using angular 2 beta RC.
Events get postponed if I include an external script I wrote into any angular 2 project:
<script>
(function(r,a,k,e,y,o,u){r['RakrWidgetObject']=y;r[y]=r[y]||function(){
(r[y].q=r[y].q||[]).push(arguments)},r[y].l=1*new Date();o=a.createElement(k),
u=a.getElementsByTagName(k)[0];o.async=1;o.src=e;u.parentNode.insertBefore(o,u)
})(window,document,'script','//cht.technology/rakr.js','rakr');
rakr('//localhost:3000', 'RAKR-000001');
</script>
Take github project thelgevold/angular-2-samples for example, once I add the below script as I did in https://github.com/tan9/angular-2-samples/tree/event-postponed branch.
The angular 2 application starts to behave strangely, some event changes won't be taking into account by angular until I trigger another event manually, I have to click a button twice to get correct rendering as this recording I uploaded to imgur
I don't know what's happening to the external script I wrote, it's a simple project that only depends on html2canvas and es6-promise, which can capture screenshot using html2canvas and send it to another web service. The bundle was built by webpack, and I tried to build the bundle by using browersify, with no luck.
This is a caveat with how Zone.js works. Zone.js patches async browser events and provides an API in which Angular uses to determine when changes happen and when to run change detection in order to update the UI.
In the case of your third-party library that uses the browser Promise API, it needs to be loaded before Zone.js is loaded via script tag. This is so that async events are patched so it will be run in the "zone" that Angular runs in. Events running outside the zone won't be picked up unless change detection is run manually, or the event is run in the context of the Angular zone.
As explained by brandon, make the code run inside Angulars zone
inject NgZone
constructor(private ngZone:NgZone){}
...
this.zone.run(() => ... /* code here that modifies Angulars model from the outside */);
You can also get the zone outside Angular
bootstrap(AppComponent, ...).then((ref => ref.instance.injector.get(NgZone));
(Not sure if this is 100% correct, I'm just on my phone and looking up is cumbersome. Please post a comment if you can't make it work.

Click-To-Call feature for Dynamics CRM (like Lync/Skype)

Advance warning: Im an absolute newbie to Dynamics CRM!
Intention
I want to have a feature like Lync/Skype integration but use my own URL. (Click on any telephone number inside CRM and call it).
For eg. assuming I have a web service which can initiate a call per URL: http://telephony.com/call?nr=012345678. Now, whenever a CRM user clicks onto a telephone number field (in forms and views) inside the CRM my web service should be called instead of Skype/Lync.
In fact I'm trying to reproduce sth. like the InGenius Connecter.
Attempts
I already tried to inject a JS web resource to a specific formular (in my case it was the default contact form) and override the Mscrm.ReadFormUtilities.openPhoneClient callback (which seems to handle the Lync/Skype integration).
function load() {
// override integrated CTC (Lync/Skype)
Mscrm.ReadFormUtilities.openPhoneClient = function (telephoneNr) {
// redirect user to my web service
window.location.replace("http://telephony.com/call?nr="+telephoneNr);
return;
}
}
Found this method at: Disable Lync completely
This does work well in forms of Dynamics 2015 (my custom link pops up instead of Skype/Lync). However, this does only work on entity forms since I can't inject web resources into an entity view.
My other ideas how to implement such a feature are:
Inject global JS resource which disables Lync/Skype and encapsulate every telephone number with link to my custom URL.
Extend/Manipulate Lync/Skype integration to use my custom URL instead of Lync/Skype.
Write plugin which encapsulate telephone numbers server side.
Question
Since I have a grasp understanding of Dynamics and no experience in plugin/resource development, I'm left a bit confused with these questions.
Is it possible to achieve any of the three ideas above ?
If not, any idea how InGenius solved this problem ?
Do you have any other idea/resources about this topic ?
Currently I found two options available to achieve a custom CTC feature. (Both has the downside of not being officialy supported by the dynamics crm.)
Global Ribbon
Pretty simple: Add a Click-To-Call button to global ribbon which is only enabled on specific grids when one row is selected.
This button refers to an JS-Action which retrieves the telephone number via ODATA and then launches the dial process.
Global Ribbon CustomRule injection
Add a global button to ribbon which refers to a JS resource per <CustomRule>. The JScript then unbinds all actions from links with .ms-crm-Phone classes and replaces its href-attribute.
This would be useful if one want to override the integrated "Skype / Lync - Click to Dial" feature with his own logic.
I didn't test this method until now, so I can't guarentee it's working !
Note: I will include example scripts as soon I got the time.

Resources