Monday, April 4, 2011

Autonomy Interwoven TeamSite javascript

The following javascript uses Form API to change the visability of dropdown boxes of the content entry form:
/*************************************************************************************
 Script: datacapture.js

 Usage: Insert the following line into the datacapture template

  <script language="javascript" src="/iw-mount/default/main/branchname/STAGING/templatedata/site/standard/presentation/datacapture.js"/>


 The init() function is executed at the end of this script.

 It register registers event handlers, and calls them to

 set the initial state of the form.

*************************************************************************************/
function init() {
 IWEventRegistry.addItemHandler("/Master", "onItemChange", typeMaster);
 typeMaster(IWDatacapture.getItem("/Master"));
 IWEventRegistry.addItemHandler("/Page_Type", "onItemChange", typeHandler);
 typeHandler(IWDatacapture.getItem("/Page_Type"));
}

function typeHandler(typeItem) {
 // Show Category combo-box based on selected Page_Type radio-button option
 var pagetypeValue = typeItem.getOptions()[typeItem.getValue()].value;
 var areaVar = IWDatacapture.getItem("/Page_Type");

 for (var i = 0; i <= areaVar.getOptions().length; i++) {
  if (pagetypeValue == areaVar.getOptions()[i].value) {
   setItemVisibleStatus (IWDatacapture.getItem("/Category" + (i + 1)), true);
  }
  else {
   setItemVisibleStatus (IWDatacapture.getItem("/Category" + (i + 1)), false);
  }
 }
}

function typeMaster(typeItem) {
    var mastertypeValue = typeItem.getOptions()[typeItem.getValue()].value;
    var reqItem = IWDatacapture.getItem("/Masters_Location"); 
    if (mastertypeValue == "n") {
     setItemVisibleStatus (reqItem, false);
    }
    else {
     setItemVisibleStatus (reqItem, true);
    }
}

function setItemVisibleStatus(item, status) {
    item.setVisible(status);
}  

// Call the initialization routine on load.           
IWEventRegistry.addFormHandler("onFormInit", init);
 
If you find this script useful please donate generously.

No comments:

Post a Comment