Thursday, August 13, 2009

Creating Popup windows and mouse over in PeopleSoft pages using ISCRIPT

This article explain how to create popup windows and mouse over in PeopleSoft pages using iScript and HTML objects which may not be possible with regular PeopleCode. I had a requirement where I need to show comments in the workflow summary grid as hyperlink due limited space. When user keeps the mouse over the hyperlink, system should display the comments text and when clicks on the link a popup a window with comment text should get displayed which facilitates the user to copy comments into a clipboard.

I am publish as it might be useful to people in the PeopleSoft community

Below are the steps to achieve it

Ø I created approval summary grid with comments column as HTML area and assigned to derived work record field.

Ø Approval summary page activate event, I have written the following PeopleCode

/*Initialize the Variables*/
&MyScriptURL = CreateArray(&string1);
&RS_HPWFSUMMARY=GetRowSet(Scroll.HP_APPR_SUMMARY);

Ø The following code create a URL string that represents an absolute reference to the specified iScript for the content servlet and stores in an array of string which will be utilized in the later part of page PeopleCode

For &k = 1 To &RS_HPWFSUMMARY.ActiveRowCount
&MyScriptURL [&k] = GenerateScriptContentURL("EMPLOYEEPORTAL", "ERP", Record.WEBLIB_AP_HP, Field.ISCRIPT1, "FieldFormula", "IScript_NAIC",VOUCHER.VOUCHER_ID, VOUCHER.BUSINESS_UNIT) "&PARAM1=" &RS_HPWFSUMMARY(&k).HP_APPR_SUMMARY.HP_APP_STEP.Value;
End-For;

Note: VOUCHER.VOUCHER_ID, VOUCHER.BUSINESS_UNIT) "&PARAM1=" HP_APP_STEP.Value are the key values passed to the iScript function

Ø Definition of Iscript function

Declare Function PTGetStyleSheetURL PeopleCode FUNCLIB_PORTAL.PORTAL_GEN_FUNC FieldFormula;
Declare Function SetDocDomainForPortal PeopleCode FUNCLIB_PORTAL.TEMPLATE_FUNC FieldFormula;

Function IScript_NAIC()
&Comments = " ";
&Business_Unit = %Request.GetParameter("BUSINESS_UNIT");
&Voucher_Id = %Request.GetParameter("VOUCHER_ID");
Rem : Get the Step and Comment Detail for all where comments exist ;
&SQLString = GetSQL(SQL.HP_AP_SUMMARY, &Business_Unit, &Voucher_Id);
/*This reads the data from Approval summary record and append into string*/
While &SQLString.Fetch(&HP_app_step, &oprid, &descr254, &dttime_added)
SQLExec("select oprdefndesc from psoprdefn where oprid = :1", &oprid, &oprdefndesc );
&Text = GetHTMLText(HTML.HP_AP_TEXT, &HP_app_step, &oprid, &oprdefndesc, &dttime_added, &descr254);

Ø /*Definition of HTML object HP_AP_TEXT*/
/span style="font-size:+0;"/
/br size="11">/b/%BIND(:1) : %BIND(:2)(%BIND(:3)), wrote on %BIND(:4) : //b/

/i class=" pstext">%BIND(:5) /i///span/


&Comments = &Comments &Text;
End-While;
&domainScript = SetDocDomainForPortal();
&HTML = GetHTMLText(HTML.HP_AP_COMMENTS, PTGetStyleSheetURL(), &Comments, %Request.ResetTimeoutURL, %Response.GetImageURL(Image.PT_OK), &domainScript, %Response.GetJavaScriptURL(HTML.PT_SAVEWARNINGSCRIPT));
%Response.Write(&HTML);

Ø /*Definition of HTML HP_AP_COMMENTS */

/link href="%Bind(:1)" type="text/css" rel="stylesheet"/
%Bind(:5)

/table cellspacing="'0'" cellpadding="'0'" width="'300'" border="'0'"/
/tbody>/tr/td//span style="font-family:verdana,arial,helvetica,sans serif;font-size:78%;"//span/%BIND(:2)//td///tr/
/tr//td align="'center'"/

/ href="javascript:window.opener.setupTimeout();self.location="/
/mg title="OK" alt="OK" src="http://www.blogger.com/%BIND(:4)" border="'0'" //a/
/td>
/tbody//able/



End-Function;

**************************************
/*--->Continuation of page peoplecode*/
*************************************
For &k = 1 To &RS_HPWFSUMMARY.ActiveRowCount
&RS_HPWFSUMMARY(&k).HP_AP_UNAPR_WRK.SETID.Value = &SETID;
If None(&RS_HPWFSUMMARY(&k).HP_APPR_SUMMARY.DESCR254.Value) Then
&RS_HPWFSUMMARY(&k).HP_AP_UNAPR_WRK.HTMLAREA.Value = GetHTMLText(HTML.HP_COMMENTS_HTML, "None", "None", &MyScriptURL [&k]);
Else
&RS_HPWFSUMMARY(&k).HP_AP_UNAPR_WRK.HTMLAREA.Value = GetHTMLText(HTML.HP_COMMENTS_HTML, &RS_HPWFSUMMARY(&k).HP_APPR_SUMMARY.DESCR254.Value, Substring(&RS_HPWFSUMMARY(&k).HP_APPR_SUMMARY.DESCR254.Value, 1, 30) "..,", &MyScriptURL [&k]);
End-If;
End-For;
**************************************************************
Ø /*Definition of KP_COMMENTS_HTML object*/


/script type="text/javascript"/
function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
href=mylink;
else
href=mylink.href;
window.open(href, windowname, 'width=350,height=300,scrollbars=yes');
return false;
}
/script/

/pan style="font-size:+0;">"%bind(:2)"
/u>

*************************************************************

Ø Last but not least is, adding iSript function to the desired permission list

Ø Mouse over text and display of popup window is ready

Note: I have some problem while publishing this paper as the site was not taking<> so replaced with ///Please make note of it

5 comments:

ChicagoMom said...

Good work. Thank you for sharing.

Unknown said...

Hi Bro,
This is Sathish,am a fresher to PSFT. Currently am working on Campus Solutions project.
I Need your help to resolve my issue.In level 2 I have a grid,the values which am entering in grid should get populated in Mouseover popup page.

Please give me solution to completed this requirement.
If you needed I will send my code also.

Please mail the details to lasathishrec@gmail.com

Unknown said...

Please do the needful soon as possible

Unknown said...

I am getting syntax errors while trying to replicate your example. Can you please spare few minutes to discuss some of the questions I have regarding the blog? My email address is emailsshelke@gmail.com. Thank you.

Unknown said...

I am getting syntax errors while trying to replicate your example. Can you please spare few minutes to discuss some of the questions I have regarding the blog? My email address is emailsshelke@gmail.com. Thank you.