2009-12-03

On form load set some selected value for related entity pick-list

I had to set the value for related entity pick-list — filter of date for Activities of some account, like it was default Selected value.

SelectArea('Activities', 'scheduledend');
SelectArea('ActivityHistory', 'actualend');

function SelectArea(loadAreaId, selectId)
{
var navElement = document.getElementById('nav'+loadAreaId); 
if (navElement != null) 
{
 navElement.onclick = function LoadAreaOverride() {
  loadArea('area'+loadAreaId);
  var iframeid = 'area'+loadAreaId + 'Frame';
  var Iframe=document.getElementById(iframeid);
  if (Iframe != null ) {
   Iframe.onreadystatechange = function SetAllasDefault() { 
    if (Iframe.readyState == 'complete') { 
     var iFrame = frames[window.event.srcElement.id]; 
     var oSelect = iFrame.document.getElementById(selectId);
     var oOption = oSelect.options[oSelect.options.length-1];
     oOption.selected = true;
     oSelect.FireOnChange();
    }
   }
  }
 
  
 }
}
}
Put at form OnLoad() event;

Комментариев нет: