Jan 19, 2013

PeopleSoft : Creating MSExcel with new sheets through peoplecode:


Local object &oWorkApp, &oWorkBook;


&sFilePath = "C:\temp\TEST_FL.xlsx";
&sFileDestPath = "C:\temp\Test.xlsx";

&oWorkApp = CreateObject("COM", "Excel.Application");
&oWorkApp.DisplayAlerts = "False";

ObjectSetProperty(&oWorkApp, "Visible", True);
&oWorkBook = ObjectGetProperty(&oWorkApp, "Workbooks");
&oWorkBook.Open(&sFilePath);
&oWorkSheet = &oWorkApp.Worksheets("Sheet1");
&oWorkSheet.Range("A1:C5").Font.Bold = True;

&oWorkApp.WorkSheets.Add().Name = "Test";
&oWorkSheet = &oWorkApp.Worksheets("Test");

&oWorkSheet.Range("A1:C5").Font.Bold = True;

&oWorkSheet.Cells(1, 1).Value = "I'm adding stuff to be bolded";
&oWorkSheet.Cells(1, 1).Font.Bold = True;
&oWorkSheet.Cells(1, 1).Font.Size = 24;
&oWorkSheet.Cells(1, 1).Font.ColorIndex = 3;

&oWorkApp.ActiveWorkbook.SaveAs(&sFileDestPath);

&oWorkApp.ActiveWorkBook.Close();
&oWorkApp.DisplayAlerts = "True";
&oWorkApp.Quit();

Jan 4, 2013

PeopleSoft : Save Project Peoplecode into file:

If you want to save the entire peoplecode of your project you can do it through application designer.
Bellow are the steps to save peoplecode to file.

In application designer
1.Go to Edit->Find In option.
2.Enter find character as semicolon(;) and select your project.
3.Check the Save PeopleCode to file option.
4.Click Find button it will ask a file name.
5.Provide the file name and location where you want to save the file.

Then the peoplecode of your project stored into file.

Dec 30, 2012

PeopleSoft : Check whether user belongs to a role:


IsUserInRole(rolename1 [, rolename2]. . .)

Returns a Boolean value: True if the current user belongs to one or more of the roles in the user role array, False otherwise.

Example:
    
     &flag=IsUserInRole("Admin");

PeopleSoft : Passing values while transfer to another page:


&queryString = "&SOURCE=R";
            /* generate a url */
            &url = GenerateComponentRelativeURL(%Portal, %Node, MENUNAME.MenuName, MARKET.marketname,COMPONENT.componentname,PAGE.pagename,action);
           
            /* Append parameters */
            &url = &url | &queryString;
           
            ViewURL(&url, False);
Syntax:
  1. 1      GenerateComponentRelativeURL(PORTAL.portalname, NODE.nodename, MENUNAME.menuname, MARKET.marketname, COMPONENT.componentname, PAGE.pagename, action, [, keylist])
  2.    ViewURL(URL_str | URL.URL_ID [, NewWindow])
  3.    ViewContentURL(URL_str | URL.URL_ID)


Use the ViewContentURL function to launch a new browser window

Use the ViewURL function to launch the default browser

exmple:

&queryString = "&SOURCE=R";
&url=GenerateComponentRelativeURL(%Portal, %Node, MENUNAME.CH_MENU,"GBL",COMPONENT.CH_COMPONENT,PAGE.CH_PAGE,"U");
 &url = &url | &queryString;
           
 ViewURL(&url, False);

PeopleSoft : Check whether user belongs to a role through peoplecode:


IsUserInRole(rolename1 [, rolename2]. . .)

IsUserInRole() function is used to check whether current user has  the role in his profile or not.

This function returns  a Boolean value:
                                       True if the current user belongs to one or more of the roles in the user role array,
                                        False otherwise.


Example:
 local boolean &hasRole;
 &hasRole= IsUserInRole(CH_ROLE_EMPLOYEE);



&hasRole contains true if the currnet user has CH_ROLE_EMPLOYEE in his profile.