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.

22 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.