Working with JavaScript

This topic discusses information related to using JavaScript with fluid applications.

PeopleTools includes an HTML definition, PT_PAGESCRIPT_FMODE, which serves as the master list referencing other definitions containing the actual JavaScript function definitions. These JavaScript functions control a wide range of page behavior, including (but not limited to):

  • Scrolling for group boxes.

  • Accordion widget.

  • Toggle widget.

  • Grouplet.

  • Drag and drop group boxes.

  • Grid lazy scroll.

  • Carousel – (used only for scroll areas).

  • Transfer animations.

  • File attachments.

  • Search page and NavBar.

  • Related action menu.

  • Side page tabs.

  • New action buttons – Back, Home, Logout

  • Search side page.

Use the AddOnLoadScript PeopleCode built-in function to invoke delivered JavaScript functions. The following example illustrates two invocations of AddOnLoadScript:

If (IsGroupletRequest()) Then;
   AddOnLoadScript("DoRowAction(" | &nRow | ");");
End-If;

AddOnLoadScript("SetSideTopTitle('" | EscapeHTML("My M/D Component's Title") | "');");

Incorporating custom JavaScript programs is supported, but application developers and implementation teams should use custom JavaScript programs judiciously, and they should be well aware of any implications introduced by the custom code.

With the architecture of the PeopleSoft Fluid User Interface, PeopleTools provides increased flexibility and opportunity to customize. However, with that flexibility comes increased responsibility for developers to test and manage any custom code. PeopleTools can only impose logical restrictions and processing constraints on the code it delivers and tests.

When considering adding custom JavaScript programs, consider the following items:

  • All JavaScript shares the same namespace. That includes PeopleTools-delivered JavaScript, PeopleSoft application-delivered JavaScript, and your custom JavaScript. Therefore, to avoid overwriting global variables, functions, and objects defined by PeopleTools or PeopleSoft applications, you must prefix your global variable, function, and object names. For example, rather than naming your function showModal(), which would overwrite the PeopleTools-delivered showModal() function, name your function my_showModal() instead.

  • Include JavaScript files in component PeopleCode, such as PostBuild, for better performance. Otherwise, the system needs to perform extra processing, such as inserting references into the header and checking to make sure all of the styles have been downloaded and applied, and before completing the page load\activate process.

  • Avoid using custom JavaScript events on a control.

  • If there are any JavaScript errors from application loading, the page will also encounter problems loading.

  • Do not use JavaScript to change the structure of the document.

  • Don’t use JavaScript to add/change the free form styles on the controls. Use PeopleCode to change/add free form style.

  • Only add JavaScript events on the controls that do not have any system generated script.