Friday, May 27, 2011

Hiding Delivered Buttons based on condition

One way to hide PeopleSoft delivered component events buttons (Save, ReturnToList, Add, UpdateDisplay…. etc.) by using JavaScript. Follow the below steps to hide the delivered buttons.

This way can be used if we have Many pages in component and we don’t want delivered buttons on some pages. Here are steps.

Step1: Place HTML area in page and assign derived and work record (Say: HIDE_WRK)and field (Say: HTMLAREA) to it.

Create HTML Definition(Say: HIDE_BT_HTML) and Add following JavaScript.

<input type="hidden" name="USERJSINJECTION" value=""/>
<script type="text/javascript">
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
oldonload();
func();
}
}
}

function appsDisablePTControls() {

var aPTButtons = ['#ICSave', '#ICList', '#ICNextInList', '#ICPrevInList', '#ICSendNotify', '#ICNext', '#ICSpellCheck', '#ICRefresh', '#ICAdd', '#ICUpdateAll', '#ICCorrection', '#ICUpdate'];

appsDisableTable(aPTButtons,true);
}
function appsDisableTable(aPTControls,bButtons) {

var aControls, oTableNode;

var bFound = false;

var i=0;

while (i < aPTControls.length && !bFound)

{

aControls = document.getElementsByName(aPTControls[i]);

if (aControls != null && aControls.length > 0)

{

oTableNode = aControls[aControls.length-1].parentNode.parentNode.parentNode.parentNode;

if (oTableNode != null && oTableNode.id != 'RBTBHEADER' && oTableNode.id != 'RBTBFOOTER')

{

if (bButtons)

oTableNode = oTableNode.parentNode;

oTableNode.style.display='none';

bFound = true;

}

}

i++;

}
}
addLoadEvent(function() {
%bind(:1)
});
</script>
Then assign the following code to Page Activated event:
HIDE_WRK.HTMLAREA.Value = GetHTMLText(HTML.HIDE_BT_HTML, "appsDisablePTControls()");
 
Note: Refer the post for how to use Html Area: http://pawan-mundhra.blogspot.com/2011/05/run-javascript-on-your-peoplesoft-pages.html



2 comments:

krishna pandey said...

I have a component with 3 pages.I have enable save button from component properties but it's displaying only 1st page.
Is any way to enable save button in 2nd and 3rd page also using JavaScript and HTML?

Unknown said...

This removes all buttons. How do I remove just 1 ?
I tried removing ICLIST from the array but it still removes all of them.

Post a Comment