Monday, February 16, 2015

Pagelet Wizard Custom Tags

Pagelet Wizard custom transformations can use special tags documented here to insert images, message catalog entries, or to format numbers and dates. This is great when trying to format currencies or ensure multilingual compliance. The problem with "Post-Transformation Processing," as it is called in PeopleBooks, is that it requires the transformation results to be valid XML. Question: How do you get Pagelet Wizard to generate valid XML when the Xalan processor used by PeopleTools sees HTML tags and automatically generates HTML? Answer: use the <xsl:output> XSL tag. Here is a sample template that produces valid XML:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xhtml="http://www.w3.org/1999/xhtml"
    xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    exclude-result-prefixes="xhtml xsl">

    <xsl:output method="xml" version="1.0" encoding="UTF-8"
        doctype-public="-//W3C//DTD XHTML 1.1//EN" doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
        indent="yes" />

    <xsl:template match="/">
        <!-- your XSL goes here -->
    </xsl:template>
    
  <!-- identity transform templates -->
  <xsl:template match="*">
    <xsl:apply-templates/>
  </xsl:template>

  <!-- delete unmatched text -->
  <xsl:template match="@*|text()|comment()|processing-instruction()">
  </xsl:template>
  
</xsl:stylesheet>

Iscripts Example



Iscripts by Example:
Create a derived work record which starts with WEBLIB_XXXXXXXX
Include a field ISCRIPT1 which holds the peoplecode function for Iscript as show below.
Record Definition: WEBLIB_HELOWRLD

The below script , echoes the value entered in the text box.
Function IScript_HelloWorld()
Below is the code placed in fieldformula



Security:
After you create a WEBLIB record, and your functions, you must add them just as you would add a page to an application.

Adding the WEBLIB record to permission list PTPT1000. Below is the snapshot.



Click on Edit to control the type of access to the functions.
Testing: Login to PIA and copy the below URL.

http://localhost:8000/psp/hr9stg/EMPLOYEE/HRMS/s/WEBLIB_HELOWRLD.ISCRIPT1.FieldFormula.IScript_HelloWorld

Note: You need to replace 8000 with webserver port and hr9stg with the domain name.
The below script , echoes the value entered in the text box.
 
This completes the creation and testing of iscript.
Note:  You might have observed that just like the content reference which has a URL , the iscript is also a URL.
So, just like the way we register component through App designer to make the link available to the user in PIA, similar way we can register for iscript as well.
Will discuss in detail on the registring iscript in another post. Below arrow shows the registration wizard for Iscript in App Designer.

Using PeopleCode Modals: openPageletActionPageInModal (PeopleTools 8.53)

This is some useful information from Jim Marion. 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.