Wednesday, 30 July 2008

Hiding borders on IFrames with Related Regarding objects

I won't bore you with the details of how to add an iFrame that will display related regarding objects on the parent object's form, and why you might want to do that - there've already been plenty of blogs out there about that (Eg Huib Aarts' article on the subject). However, I've noticed that when I implemented my version of it, the pesky borders wouldn't go away, and the article linked to has some code in it that is meant to make the borders disappear - unfortunately, it didn't work for me, and I'm not sure why. So rather than sit through and debug it, I modified that code so that now, instead of modifying the style elements of those tables, it just rips up the child table with the important information and dumps it in the main body of the iFrame. Problem solved. There's still a slight border to the right that I can't get rid of, but if you turn the border displays off it's barely noticeable and I can live with that.

Here's the code if you're interested:

var frameName = 'IFRAME_Name';
var objFrame = document.getElementById(frameName);
var objWindow = document.frames[frameName];
objFrame.allowTransparency=true;
objFrame.onreadystatechange = function ()
{
if (objWindow.document.readyState=='complete')
{
objWindow.document.body.style.backgroundColor='transparent';
if (objWindow.document.getElementsByTagName('BODY')[0]!=null)
{
objWindow.document.getElementsByTagName('BODY')[0].style.padding='0px';
if (objWindow.document.getElementsByTagName('TABLE')[0] != null)
{
if (objWindow.document.getElementsByTagName('TABLE')[0].getElementsByTagName('TD')[0] != null)
{
objWindow.document.getElementsByTagName('BODY')[0].innerHTML = objWindow.document.getElementsByTagName('TABLE')[0].getElementsByTagName('TD')[0].innerHTML;
}
}
}
}
}

Friday, 25 July 2008

Calling CRM Webservices via Javascript

I used to be really intimidated by the idea of calling the CRM Webservice via JavaScript, but recently I have had the opportunity (read: didn't have a choice) to use it a lot, both in internal projects and for customer systems. And I realise now how stupid I was in keeping my head in the sand - the JS required to call the webservice does LOOK rather intimidating...but with some help from a fantastic tool on Stunnware (http://www.stunnware.com/crm2/topic.aspx?id=JSWebService), I soon found that, much like myself, it looks a lot worse than it actually is. I've now got a copy of that tool on my desktop set up so that I can quickly switch between the CRM3 and CRM4 versions, and am actually starting to learn to write the XML from scratch (or at least edit it to do different things without having to go through the tool).

There's just so many possibilities that this opens up. Some of the applications we've had for it include:
  • Counters for related records (much like Outlook mail folders) - one caveat is that the more of these counters you want to have, the higher the overhead and therefore the longer the page takes to load
  • Autopopulating fields - for example populating a Customer field with the parent customer of a responsible contact in the Incident entity upon population of the responsible contact
  • Summarising details from other entities on the header of another entity - best explained with a screenshot:
    The circled data is data pulled from 2 different entities, linked by the contact - and it allows our support desk personnel to quickly find out the support level on a given customer's contract.
I'd love to hear of any other applications you might have come up with for this!