Wednesday, June 26, 2013

Using PeopleCode Modals: openPageletActionPageInModal (PeopleTools 8.53)

While typing something in the Chrome JavaScript console, I managed to bring up the function openPageletActionPageInModal. Hmmm, sounds interesting. I drilled to the implementation and saw that you call it like this:

openPageletActionPageInModal("http://your.server.name/psp/ps/EMPLOYEE/HRMS/c/ROLE_EMPLOYEE.HR_EE_PERS_INFO.GBL?")

What does it do? It converts the /psp/ part of the URL to /psc/ and opens the URL in a modal dialog. For me it worked great as long as I followed two simple rules:

  • Included a question mark in the URL. If the URL has no query string parameters, just include a trailing "?".
  • Used this function in the same datababase/application as the content. In other words, I didn't try to use this technique in Interaction Hub for HRMS content. For that to work, I would need to translate more than just /psp/. I would also have to translate the server name and site name.

Note: It works just fine in a portal/content provider situation if the URL is already a /psc/ URL.

Anyway, interesting, undocumented piece of JavaScript that you may or may not find useful. As always, your mileage may vary.

Note: I was using PeopleTools 8.53 when I found this function.

32 comments:

Ciro Victor said...

I am afraid it is not working with me while applying your first rule If the URL has no query string parameters, just include a trailing "?". as will it affect the API in the end ?

Jim Marion said...

I forgot to mention that I found this in PeopleTools 8.53. Are you testing this on PeopleTools 8.53?

Jim Marion said...

I will update the post to note that I am using PeopleTools 8.53.

Lally Reyes said...

Hello! We have a problem in our application. We are upgrading to PT8.53

I am not a developer but trying to help figure out our issue.

We are using "psp" but sometimes it changes to "psc" (when we expect it consistently stay on "psp"). What could possibly cause this to happen?

Jim Marion said...

@Lally, that is interesting. It should not do that. Is this when you click the New Window link or is there any specific pattern? Does it happen when you are using menus to navigate? Are you using Interaction Hub with remote unified nav? This sounds like something that will require a case with Global Support. You may also want to ask your question in the PeopleSoft OTN General Discussion forum.

Tom Mannanchery said...

Hi Jim,

Is it possible to have a link in a pagelet in Interaction Hub, which when clicked opens a modal window with content from 'Managed Content' in it?

Thanks,
Tom M.

Jim Marion said...

@Tom, yes. The way you reference it depends on the content type. If it is something like a news publication, then you can access it through the /psc/ (or even /psp/) URL. Some content, such as non-web content, may use the various "View" PeopleCode functions. You may not be able to view that type of content in a dialog.

Tom Mannanchery said...

Thanks so much Jim. Can such a pagelet be created using the Pagelet Wizard or would it have to be a component-based pagelet?

Jim Marion said...

@Tom, Pagelet Wizard Free Text or HTML (with view source) should work fine. If you are going to use the openPageletActionPageInModal function, the JavaScript should already be available in the portal. An alternative that I prefer is to use jQuery UI's dialog widget.

Tom Mannanchery said...

Hi Jim,

Your suggestion worked. Thanks a lot. Sharing the code from the free text pagelet.


var a = document.getElementById("mylink");
a.onclick = function() {
openPageletActionPageInModal("/psc/pa91dev/EMPLOYEE/EMPL/c/EPPCM_CONTENT_MGMT.EPPCM_PUB_VIEWER.GBL?EPPCM_CONTENTID=2509&SHOW_SUMMARY=Y");
};


Open Content in Modal Window

Thanks,
Tom

Jim Marion said...

@Tom, thank you for sharing. Do you need to return "false" from your onclick function to cancel the default action?

Tom Mannanchery said...

That's a neat observation Jim. The href value is #, so I am assuming the return false is not needed. Do you think it could cause any issues?

Jim Marion said...

@Tom, I recommend returning false to cancel the default event. Otherwise, it will navigate somewhere else. That "somewhere else" just happens to be the current page. You should notice this in the URL because the URL will now have a "#". You may not notice a difference. It might work fine. It is just one of those things that may come up later to cause unexpected behavior. If possible, I like to deal with those ahead of time. I find that if I ignore things like this, then if they do cause problems, I have completely forgotten what caused them.

Tom Mannanchery said...

Thanks again Jim. I will surely make that change so that I don't have to bang my head later.

Tom

Jim Marion said...

@Tom, Exactly! :)

Tom Mannanchery said...

Hi Jim,

In the code that I posted, I have included the URL to the component that I want to open in the modal window. You may notice that its a relative URL, but the site name is 'pa91dev'. This will break when we migrate this to another env as the site name there could be pa91tst.

I was researching for a few alternatives and came across your blog post for custom transformers. Do you think that approach would be best in this case?

Thanks,
Tom

Abhay said...

i am working on 8.52. can i use this.
i have tried to populate the page in light box use below code. but not able to close it by clicking any value in the grid field(hyperlink)... can you please help me on this.

Jim Marion said...

@Tom, I absolutely, without a doubt, believe that the custom DisplayFormat is the best way to implement what you require. That is how I have it implemented. My book contains a chapter showing a custom Meta-HTML processor. I use that as the base for doing the string sequence substitutions. The DisplayFormat is very similar to the chapter on creating a custom data type.

Jim Marion said...

@Abhay, when you say, "not able to close by clicking any value in the grid," what do you mean? What happens when you click a value? Do you get an error? Also, you mention that you use lightbox with "below code," but I don't see any code below. Did you post something else?

Tom Mannanchery said...

Thanks Jim. I will go ahead with this approach and let you know how that goes.

Tom

Abhay said...

Actually i'm trying to open a page in a model window. The page is like a prompt page in peoplesoft where you search & select some value and it comes back to the parent page. i managed to open it in model window by using CSS and Iframe & javescript.

but problem is not able pass any field value (that i selected in the model window) from the model page to the calling page. in short my aim is need to create a search custom search page that should work like how prompts work is peoplesoft.

Jim Marion said...

@Abhay, you just made me realize that I incorrectly titled this post. A better title would be "Using PeopleTools JavaScript Modals: openPageletActionPageInModal..."

If you want to use response values in PeopleCode (update the component buffer) then you should choose one of the PeopleCode modal functions, such as DoModal. If you want to return values to your JavaScript, then take a look at the showModalDialog JavaScript function.

Pradeep Beura said...

Hello Jim,
I am an ardent follower of your blogs and almost 100% of times your tricks and your suggestions have helped me grow as a PS Developer.
We are in middle if a PeopleTools Upgrade to 8.53 with HR on 9.0 and Portal on 9.1. We are opening HR Pages via Portal and there is this specific transaction of Editing Home and Mail Address that allows Change Country and when we select a new Country the whole branding is lost and we get a JavaScript Error of Expected ')' at PT_AJAX_MIN.JS It points to PAndA(Eval which is a function in ScriptProxy.js which we don't know why it is loading to only this page on Change Country. Because of this the page becomes unusable and we cannot save or cancel and it hangs.
Any suggestions would do wonders.
Please note that this works fine in HR 8.49 and Portal 8.52 where Prompts were on Top of Page Content.
Thanks
Pradeep

Jim Marion said...

@Pradeep, very interesting. I suggest you log a ticket in My Oracle Support. This sounds quite unusual. Perhaps a resource (HTML definition) did not load properly during the upgrade?

Pradeep Beura said...

Thanks Jim for your response. Have raised a case but yet to hear from them

Julie said...

Hi Jim, I work for a company that has PeopleSoft CRM. We are implementing 9.1 this weekend. We did not implement the multiple attachment feature which became available in PeopleTools 8.53. I have been trying to research how this would function. I want to actually see the screen the customer sees to browse for the attachments. Do you have suggestions of where I can see this? Thanks

Jim Marion said...

@Julie, are you looking for a delivered page that uses this new feature? I'm not familiar enough with application specific functionality to know. If I were attempting the same thing, I would probably just create a test page in my dev environment and implement the multiple attachment functionality.

John Jackson said...

Was wondering if you could offer some advice. My company is using peoplesoft portal with tools version 8.53. We are trying to get a navcollection to open its links in a modal set up. I have a javascript working in chrome and FF but IE is not cooperating at all I am using the openPageletActionPageInModal code you mentioned at the top of the page to accomplish this in a script that sits outside of the pagelet itself and only fires after the pagelet is loaded. Do you have any advice on a probable fix. I have been experimenting with trying to rewrite the xslt that drives the page to apply the openPageletActionPageInModal code to the links that is contains but am not having much luck there either. Any advise would be very much appreciated.

Jim Marion said...

@John, open the IE developer tools window and see if an error appears in the JavaScript console. This is a good way to figure out what is causing the problem in IE.

John Jackson said...

Thanks I tried that but it doesn't throw an error. For a bit of a further explanation of the overal problem the script was originally working but we were still getting either new tabs opened up or the current window taken over due to the settings on the links the pagelet. My attempts at removing those target tags did not have any affect towards making it work. In the end I reworked the xsl to not build out the hrefs for the links and keep the links housed in the script itself(did not want to do that this way but was all I could do to get it to work). Now the scripts works as expected in Chrome and FF but IE just continually reloads the home page when the links are clicked instead of opening the modal window. So at this point I am running out of ideas.

Jim Marion said...

@John, do you have an href attribute with no value or "#" for a value? If so the browser interprets that to mean, "reload the page." If you have an onclick handler, are you canceling the event? Browsers (and versions) have different methods for canceling events. Make sure you do that correctly. To ensure that your event handler is called, put something like console.log('onclick') in your JavaScript event handler. Or, since the console will clear when the page reloads, use alert('onclick') instead.

Jim Marion said...

@John, also, don't use document.write in your pagelets. That will cause the homepage to reload.