Monday, January 13, 2020

A Refresh-able URL

I find development to be an iterative process. I often create a shell of a program (module, component, page, etc.), just enough to test, and then run my first test. I then iteratively enhance the program (module, component, page, etc.), verifying and validating each change. For online PeopleSoft pages and components, this often means pressing the browser refresh button a LOT! But here is the problem: each time I refresh a PeopleSoft component, PeopleSoft reverts to the search page. After selecting a search value, I'm then directed to the first page in the component. What if I'm testing a different page? Is it possible to craft a URL to bypass component search and open a different page within the component? Yes! We can bypass component search by placing level 0 search key field names and values in the URL. Likewise, we can specify the starting page by placing the Page=... parameter in our URL. But if you don't know the component's search keys and the target page's name, do you have to find them in Application Designer? Fortunately, no. Every PeopleSoft page contains a JavaScript variable named strCurrUrl. This variable contains the current full URL, including search keys and Page parameter. Here is an example of a URL we might use to open the Job Earnings Distribution page of the JOB_DATA component for an employee with the ID KU0001:

http://hr92u030.example.com:8000/psp/ps/EMPLOYEE/HRMS/c/ADMINISTER_WORKFORCE_(GBL).JOB_DATA.GBL?EMPLID=KU0001&EMPL_RCD=0&PAGE=JOB_DATA_ERNDIST

For the last several years, we have been showing customers a simple JavaScript console trick to move the strCurrUrl JavaScript variable into the browser's address bar, allowing us to bypass search and navigation when testing PeopleSoft pages. The real trick to this, though, is that Fluid and Classic behave a little differently, requiring different JavaScript. So today, I want to share a simple JavaScript fragment that you may use across Classic and Fluid. This small snippet is "smart" enough to apply the correct rule on Fluid or Classic. It also has a little logic to detect Classic content in Fluid Activity Guides and Fluid WorkCenters. Please note that using this script with a Fluid Activity Guide/WorkCenter will open Classic content outside of the WorkCenter/Activity Guide frame, but then for testing purposes, that is often desirable.

OK... so... wait, it gets better. Why copy and paste that script into the JavaScript console every time you want to invoke it? Why not just create a browser bookmark or favorite to accomplish this task (also known as a bookmarklet)? Here is the same script in bookmark form. Simply drag this hyperlink into your browser's bookmarks bar and you have a bookmark you may use on almost any PeopleSoft component to get a refresh-able URL.

PS Refresh-able

Are you interested in more tips like this? Jim Marion shares tons of them in his training classes. Register today for one of our upcoming classes!