| Bookmarklets and PeopleSoft |
|
| Written by Brent Martin | |
| Friday, 08 June 2007 | |
|
Bookmarklets are little Java programs contained in a bookmark that can (among many other things) dynamically generate a URL and send your browser to it. While I’m not crazy about the name, they’re awesome when you’re working in PeopleSoft because you can have a set of buttons on your bookmarks toolbar that’ll work across all of the PeopleSoft environments you have to log in to. I use Bookmarklets for basically three different purposes: 1) To replace the “Favorites” functionality built into PeopleSoft so that I don’t have to maintain favorites in different environments; 2) To jump to the component I’m currently viewing in a different environment; and 3) To call iScripts and Servlet Directives within the context of the current environment. Replacing the Favorites functionality Don’t get me wrong, the Favorites functionality in PeopleSoft is good. But the problem is that it’s a pain to set up the same favorites in Dev, Test, Production, Demo, etc. But I can set up a bookmarklet that will take me to a folder or component in the current environment. And if the DBA creates a new environment, my bookmarklets will still work. Say you’re logged on to an environment called FDEV90 adding new departments. The URL in your browser might look like this: http://dev.erpassociates.com:11000/psc/FDEV90/EMPLOYEE/ERP/c/DESIGN_CHARTFIELDS.DEPARTMENT.GBL You could add this to your favorites in your browser, but it’ll only work for FDEV90, not for say FTST90. But a bookmarklet can build its own URL by taking the first part of the URL (i.e. http://dev.erpassociates.com:11000/psc/FDEV90) , appending the page you want to bookmark (i.e. /EMPLOYEE/ERP /c/DESIGN_CHARTFIELDS.DEPARTMENT.GBL), and redirecting your browser to this new URL. Here’s what a bookmarklet looks like that will take you to process monitor of whatever environment you happen to be working in: javascript:(function(){var t = %22EMPLOYEE/ERP/c/PROCESSMONITOR.PROCESSMONITOR.GBL%22; var u = location.href.replace(new RegExp(%22(?=EMPLOYEE)[\\S\\s\\w\\W]+%22,%22%22),t); location=u; })() Scary, huh! This is really just a 3-line javascript. Here’s what the Javascript does: var t = “EMPLOYEE/ERP/c/PROCESSMONITOR.PROCESSMONITOR.GBL”; -- Variable t gets assigned to what we want to bookmark var u = location.href.replace(new RegExp("(?=EMPLOYEE)[\\S\\s\\w\\W]+",""),t); -- This invokes a regular expression to identify the part of the URL that starts with EMPLOYEE to the end, and replace it with variable t. It assigns the new value to a variable called “u”. location=u; -- This tells the browser to set the location to u and go there. The other stuff is just wrappers so that your browser can translate it the same way it would any javascript function it finds on a web page.
Jump to the current component in a different environment Say you need to set up a new department in your Development, Conversion and Test and databases. It’s kind of a pain, isn’t it? You have to log on to development, navigate, enter the data, log out, and repeat the process in Conversion, then finally in Test. There is a better way. Your environments probably all trust each other through the magic of PeopleSoft’s Single Sign on functionality. So say your development URL looks like this when you’re on the department page: http://dev.erpassociates.com:11000/psc/FDEV90/EMPLOYEE/ERP/c/DESIGN_CHARTFIELDS.DEPARTMENT.GBL If you manually edit the URL in your browser and change the server name, port number, and site name to the correct values for your conversion environment, you’ll automatically go there (assuming Single Sign On is set up correctly): http://dev.erpassociates.com:12000/psc/FCNV90/EMPLOYEE/ERP/c/DESIGN_CHARTFIELDS.DEPARTMENT.GBL That saves you from having to sign in and navigate. And guess what? A Bookmarklet can do these tedious replacments much like the “Favorites” Bookmarklet did in the previous example. The only difference is that we’re working with the part of the URL before the /EMPLOYEE/, where the previous bookmarklet worked with the part of the URL After the /EMPLOYEE/. Here’s a javascript program to do replace the server, port and web site with a new one: var u = location.href; -- set u to the current browser URL location = u.replace(new RegExp("^http\:\/\/[A-Za-z0-9_.:/]+(?=EMPLOYEE)",""),"http://dev.erpassociates.com:12000/psp/FCNV90/"); -- Use a regular expression to match the first half of the URL up to the EMPLOYEE keyword, and replace it with a new hard-coded value. Then assign this to the Location variable so the browser will go there. Not too shabby. But what if you’re not already logged in but you want to just go to the sign in screen? The function won’t do anything because it won’t find any replacements to make. And it’s SUCH a pain to use a different bookmark to take you to the sign in screen. Well, don’t worry. This version will take you to the login page if the search/replace didn’t do anything: var t = %22http://dev.erpassociates.com:11000/psp/FDEV90/%22; var u = location.href.replace(new RegExp(%22^http\:\/\/[A-Za-z0-9_.:/]+(?=EMPLOYEE)%22,%22%22),t); if(u==location.href) {location=t + "?cmd=login";} else {location = u}; But it might be cool to have it take you to the Default page instead of the sign in page. That way, if you are signed in on another tab or in another browser you can bypass the log in page. If you’re not signed in, you’ll still get the log in page. Here’s how that might look: var t = "http://dev.erpassociates.com:11000/psp/FDEV90/"; var u = location.href.replace(new RegExp(%22^http\:\/\/[A-Za-z0-9_.:/]+(?=EMPLOYEE)%22,%22%22),t); if(u==location.href) {location=t + %22/EMPLOYEE/ERP/h/?tab=DEFAULT%22;} else {location = u}; To turn this into a real bookmarklet, you need to put it all on a single line, and put a javascript wrapper around it. The final version looks like this: javascript:(function(){var t = "http://dev.erpassociates.com:11000/psp/FDEV90/"; var u = location.href.replace(new RegExp("^http\:\/\/[A-Za-z0-9_.:/]+(?=EMPLOYEE) ",""),t);if(u==location.href) {location=t + "/EMPLOYEE/ERP/h/?tab=DEFAULT";} else {location = u};})() To make this work in your environment, you just need to change hyperlink on the line that begins with var t= to a valid value for one of your environments. Then right-click your bookmark (or links) toolbar in your browser, select New Bookmark (or Create Shortcut), give it a name, and paste the entire javascript line into the URL field. Repeat the process for each of your environments. Now you can move between environments as if they were all one big application -- which is how it should be. Administrators’ Tip: Your production environment shouldn’t allow single sign on from non-production environments. If you log on to Development and alter the URL with values for your Production web server, you should always get a sign in page. If it goes directly into the application it means someone with access in development could reset someone’s password in development, log on as that user, and use single sign on to become that user in production. Scary, huh! The easy fix is to pull up your Trusted Local Node in the integration broker configuration, and set the password to something unique for production, and save it. There may be better fixes – if you’re interested leave a comment and we can discuss pros and cons. Calling Servlet Directives and IScripts Servlet Directives let you do things like reload your web profile on the fly, clear web server cache, etc. You generally append something that looks like ?cmd=reloadconfig&pwd=dayoff to the URL for your environment. This bookmarklet clears web server cache: javascript:(function(){var t = %22?cmd=purge&pwd=dayoff%22; var u = location.href.replace(new RegExp(%22(?=EMPLOYEE)[\\S\\s\\w\\W]+%22,%22%22),t); location=u; })() This bookmarklet reloads the web profile: javascript:(function(){var t = %22?cmd=reloadconfig&pwd=dayoff%22; var u = location.href.replace(new RegExp(%22(?=EMPLOYEE)[\\S\\s\\w\\W]+%22,%22%22),t); })() And this bookmarklet tells you what the web server thinks your web profile looks like: javascript:(function(){var t = %22?cmd=viewconfig&pwd=dayoff%22; var u = location.href.replace(new RegExp(%22(?=EMPLOYEE)[\\S\\s\\w\\W]+%22,%22%22),t); location=u; })() Be sure to change the &pwd=dayoff to whatever password your administrator is using. Chris Heller over at Grey Sparling has a great article on bookmarklets with an IScript. His Bookmarklet figures out what page you’re on and passes the information to an iScript which brings up the Portal Structure and Content for the page you were just on. That’s an awesome tool for a security administrator who has to figure out why a page isn’t showing up for a user or to otherwise troubleshoot portal security interactively. That’s my current Bookmarklet to an iScript example, but I plan to write more as time allows. I’d like to create one that would call the Switch User function for security troubleshooting. I’d like to build another that turns on SQL tracing, and a third to show me the log file through the browser. I hope you find bookmarklets to be as interesting and cool as I have. If you’d like to read more, check out http://www.bookmarklets.com or http://www.squarefree.com/bookmarklets/. Happy boomarkleting!
|
|
| Last Updated ( Tuesday, 12 June 2007 ) |
| < Prev | Next > |
|---|
