Tuesday, October 29, 2013

Mobile Approvals using Integration Broker and DataPower ESB

Recently I was playing around with JDeveloper trying to build an mobile approval application to allow managers to approve AWE transactions via their mobile device.  That is when I had the idea to use Integration Broker to generate an XML document that would contain an HTML Document wrapped in a CDATA, then I could use a simple XLST on the response to remove the HTML document from the XML and send it to the manager's mobile device via DataPower.   DataPower would be utilized to get through our firewall and to change the content-type from xml/text to html/text.  Basically, I am using DataPower as a web server.  So you could also accomplish this same thing without DataPower, you could use a Apache web server with mods headers or even PHP could be used to change the headers.


       1.  Create simple Login Screen and place on external web server
 
     2.  Build one Synchronous Integration Broker Message with handler


     3. Create an “Any to Local” Routing and configure it to utilize XLST to transform the response from XML to HTML


        <?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html" omit-xml-declaration="yes"/>

<xsl:template match="/">
<xsl:value-of select="/" disable-output-escaping="yes"/>
</xsl:template>

</xsl:stylesheet>
  4.  Use Enterprise Service Bus or external Web server to handle change HTTP header content from XML to HTML
  5.  Build WorkList table with transaction details and URL or button to Approval Pages.
 
 
  6. Build Transaction Specific Approval pages using HTML5 and CSS

This was the presentation I gave a couple of weeks ago at the KCRUG, in my next post I will attempt to go into more regarding the Integration Broker handler.

Monday, October 28, 2013

Disabling the back button in PeopleSoft

I was asked to disable the back button in the browser for ePerformance. However, based on my research you I concluded that the back button cannot be disabled and nor would I want to disable it if I could.  So what can you do to prevent users from losing their work, by using the back button in PeopleSoft?  The answer appears to be the onbeforeunload event in the browser.  This event is designed to prompt the user if they really want to leave the page and potentially lose their changes.  To implement this I needed to add the following JavaScript to the page I wanted to prevent the user from losing their changes.

1. Modify the onbeforeunload to warn the user if the page has changed and they are navigating away from the page.
window.onbeforeunload = function(e) {
           var changes = checkFormChanged(document.%formname);
if (changes)
{           
  return "You have unsaved changes, please save them."
}
}

2.add some JavaScript to clear out the onbeforeunload if they user selected a link/button on the page.
function adaptLinks() {
    var links = document.getElementsByTagName('a');
    for (i = 0; i != links.length; i++) {
        links[i].onclick = (function () {
            var origOnClick = links[i].onclick;
            return function (e) {
                 window.onbeforeunload = function(){};
                if (origOnClick != null && !origOnClick()) {
                    return false;
                }               
            }
        })();
    }
}
adaptLinks();


3.  Finally, I  Monkey Patched the endModalCntrl to clearout the onbeforeunload if they used the "X" to close out a modal window. 

 (function() {
  var originalendModalCntrl = ptCommonObj.endModalCntrl;
  ptCommonObj.endModalCntrl = function() {
    window.onbeforeunload = function(){};
    return new originalendModalCntrl();
  }
})();

Special thanks to Jim Marion for #3

Now when the user clicks the back button or changes the url they are prompted by the page that they have unsaved changes, like this:





Thursday, October 10, 2013

Using the Related Content Framework to avoid Customizations

We run a pretty Vanilla shop here and we frown upon unnecessary customizations to the applications, but with that said we do have a few customizations.  To be precise we have 18 total objects customized.   So when I got a request to add the ability for employees and managers to add attachments to the ePerformance Appraisal document, I searched for a way to do this without touching the delivered pages.  This got me thinking about Related Content, if I could create a simple Component that used the Appraisal Document ID as a key and I shared this Related Content with both the EP_APPR_MAIN1 and the EP_APPR_BASE1 pages, then managers and employees could attach and share documents regardless of what phase the document was currently in.


So I built a Component that was keyed by Appraisal ID and allowed for multiple Documents to be attached.
Then I created the assigned the Related Content at the page level.

Assigning Related Content to Page

 Then press the configure button to pass the Document ID to the related content component.

Make sure you click the Related Content Menu at the bottom!


  Now when I navigate to the Establish Criteria, it has the related Content Menu on the top right and the bottom o the page now has a place for employee's to add attachments.  And since the key is just he document id, all I have left to do is to configure the Manager and Employee evaluation pages to share this content.



Wednesday, October 9, 2013

App Package PeopleCode-"There is no current buffer context."

I was tasked with automating a couple of ePerformance Tasks for our end users and one of those tasks was transferring a document to the next supervisor in the chain of command when the supervisor assigned to the document vacates the position.  At first I thought I would just create a CI and replicate what the user does manually, but when I created a CI of the  EP_APPR_XFER component and tried to use it, I got a plethora of .Null errors.  So I did some research and discovered that the component was just calling the TransferDocument method in the Application Package PeopleCode in the EP_FUNCTIONS:EP_Utilities.   So I decide to just write a simple Application engine step to load a rowset of documents reporting to empty positions and call this method.  But what should have been so easy, ran to "No Success"! 

There is no current buffer context. (2,681) EP_FUNCTIONS.EP_Notification.OnExecute Name:Format_EP_E mail PCPC:24289 Statement:421 Called from:EP_FUNCTIONS.EP_Notification.OnExecute Name:EP_Notify Statement:588 Called from:EP_FUNCTIONS.EP_Utilities.OnExecute Name:TransferDocument Statement:343 Called from:ZZ_EPDOCS.XFR.GBL.default.1900-01-01.Step01.OnExecute Statement:22
I really wish Oracle would adopt a standard that Application Package PeopleCode should not be tied to the Component Buffer.  In order to get around this I cloned the entire EP_UTILITIES and removed the references to the Component Buffer.  Now I am a novice when it comes to Application Package PeopleCode.  I have written a few of my own packages, all of which are independent of the component buffer, but I wonder if I should have extended the EP_UTILITIES, of if cloning the package was the best option?