15. Oktober 2014 11:42
I looked into being able to host the Notes list from a related entity in an IFRAME of a parent entity. It works but with unfortunate caveat.
What to do
Create a new Entity, for instance 'Alternate Notes'
Create N:1 relationship between 'Account' and 'Alternate Notes'
Place the corresponding 'Alternate Notes' lookup attribute on the Account form
Upon creation of an 'Account' entity instance, create and attach an 'Alternate Notes' entity instance via Workflow
Create an IFRAME in Account; populate the src with the following:
var lookupItem = crmForm.<alternatenoteslookupattribute>.DataValue;
if (lookupItem != null) {
crmForm.all.IFRAME_AlternateNotes.src = prependOrgName("/_controls/notes/notesdata.aspx?id="+ lookupItem[0].id + "&ParentEntity=3&EnableInlineEdit=false&EnableInsert=false");
}
else {
crmForm.all.IFRAME_AlternateNotes.src = "about:blank";
}
The IFRAME will now display a Notes viewer that looks exactly the same as for those attached to the Account, but the content will correspond to the attached 'Alternate Notes' entity instance.
The caveat
Unfortunately, the code behind the Notes control "hardcodes" the "parent" entity instance for the Notes being edited/added to be the GUID of the entity for which the form is being displayed (ie. the 'Account'), not the GUID of the entity that is passed to "notesdata.aspx" (ie. the 'Alternate Notes').
This causes all attempts to add/edit Notes to fail with the following error:
"The requested record was not found or you do not have sufficient permissions to view it"
For this reason, you must make sure that the following parameters are set to false, as per the example above:
EnableInlineEdit=false&EnableInsert=false
So, the Notes control will "look" just like the 'Account' notes while displaying notes for the 'Alternate Notes', but you can't edit them directly. To edit, you must click on the 'Alternate Notes' lookup field and edit the Notes there.
A bit clunky, but not bad, if it's more important to you to display the notes in a common format, than to edit them inline.
16. Oktober 2014 08:19