Tuesday, April 12, 2011

How Select Options are Set on a PeopleSoft Page


I just learned something new about how PeopleSoft pages work. We are using PeopleTools 8.49.29. Your mileage may vary.

It appears that if more than one Select (dropdown) have the same options, PeopleTools puts the options into a JavaScript array, then populates the options with JavaScript after the page loads. I learned this the hard way because I had a jQuery function that ran on page load and uses the select values. It was not working right because the select values were not set when the script ran.

The function that populates the options and sets the selected values is setSelectElemOptions_win0(). I solved my problem by creating a proxy for this function and adding a call to my function. This ensures that my function runs after the Select options are set. See my previous post on how to create a proxy.


Here's the code.


// proxy the setSelectElemOptionsProxied function to ensure Select Options
// are set before totalHours is called on page load
var setSelectElemOptionsProxied;
(function() {
// proxy setSelectElemOptionsProxied
setSelectElemOptionsProxied = setSelectElemOptions_win0;
setSelectElemOptions_win0 = function() {
setSelectElemOptionsProxied(); // call the original function
totalHours(); // my function
};
})();




No comments:

Post a Comment