Here the PeopleCode function to generate an email with attachment
&RET = SendMail(&MAIL_FLAGS, &MAIL_TO, &MAIL_CC, &MAIL_BCC, &MAIL_SUBJECT, &MAIL_TEXT, &MAIL_FILES, &MAIL_TITLES, &MAIL_SENDER);
&MAIL_FLAGS = 0;
&MAIL_TO = "Mail To";
&MAIL_CC = "CC To>";
&MAIL_BCC = "BCC";
&MAIL_SUBJECT = "Mail Subject";
&MAIL_TEXT = "Body of the email";
&MAIL_FILES = "Absolute path of the file including file name";
&MAIL_TITLES = "File attachment appear with this name";
&MAIL_SENDER = "Sender name";
Try to get the value of variables from the message catalog.
&RET = SendMail(&MAIL_FLAGS, &MAIL_TO, &MAIL_CC, &MAIL_BCC, &MAIL_SUBJECT, &MAIL_TEXT, &MAIL_FILES, &MAIL_TITLES, &MAIL_SENDER);
If Not (&RET = 0) Then
WinMessage("Return status from mail = " | &RET);
End-If;
Monday, September 14, 2009
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
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 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
Labels:
Iscript,
Mouseover,
PeopleSoft,
Popupwindow
Subscribe to:
Posts (Atom)