How to Use Encrypt – Decrypt Password in Peoplesoft

How to Use Encrypt Password in Peoplesoft

You can use peoplecode function of peoplesoft  for encrypt password for security

For example for use encrypt peoplecode function of Peoplesoft 

Define Key for encrypt contain key 1 and key 2

/* 1 defind key1 = “testkey1” = key1 help Encrypt */

&Key1= “testkey1″;

/* 2 encrypt key1 with key2 for input key 2=Jimmy */

&Key2 =”Jimmy”;
&Password= Encrypt(“testkey1”, RTrim(LTrim(“Jimmy “)));

WinMessage(&Password, 0);
&Password is Data encrypt

or use this statment

&Password= Encrypt(&Key1, RTrim(LTrim(&Key2)));

For example for use Decrypt peoplecode function of Peoplesoft 

&decrypt_password = Decrypt(&key1, RTrim(LTrim(&Password)));
WinMessage(&decrypt_password , 0);

How to Hide or Unhide Row or Table in Grid on Level 1 By Peoplecode of Peoplesoft

How to Hide or Unhide Row or Table in Grid on Level 1 By Peoplecode of Peoplesoft

You can use Peoplecode in page activate or action field change  for hide all row in grid record level 1 or Unhide all row in grid record level 1.

For Example.  Define Page and a grid has record in level 1 on page. User has to hide grid when effdt not in this year and show or unhide grid when effdt in this area.

If you want to Hide Record in grid of Peoplecode on level 1

For &ROW = ActiveRowCount(Record.Record_Name) To 1 Step – 1
HideRow(Record.Record_Name, &ROW);
End-For;

If you want to Unhide Record in grid of Peoplecode on level 1

For &ROW = ActiveRowCount(Record.Record_Name) To 1 Step – 1
HideRow(Record.Record_Name, &ROW);
End-For;

How to use peoplesoft sendmail function with attachment by peoplecode

How to use peoplesoft sendmail function with attachment by peoplecode

You can use send html email and file attachment by peoplecode use sendmail function

&MAIL_FLAGS = 0;
&MAIL_CC = “”;
&MAIL_BCC = “”;
&MAIL_SUBJECT = “”;
&MAIL_TEXT = “”;
&MAIL_FILES = “”;
&MAIL_TITLES = “”;
&MAIL_SENDER = “Test@mail.com”;
&MAIL_SUBJECT = &Subject_mail;
&MAIL_TEXT = &Content_Mail;

&CONTTYPE = “Content-type: text/html; charset=utf8”;
&MAIL_SEP = “;”;

/*Path Report of Report Server or path websever*/

&MAIL_FILES = “C:\temp\Filename.doc”;
&MAIL_TITLES = “Filemame.doc”;

&RET = SendMail(&MAIL_FLAGS, &MAIL_TO, &MAIL_CC, &MAIL_BCC, &MAIL_SUBJECT, &MAIL_TEXT, &MAIL_FILES, &MAIL_TITLES, &MAIL_SENDER, &MAIL_SEP, &CONTTYPE);

How to Remove Special Characters from String in Peoplecode

How to Remove Special Characters from String in Peoplecode

You can remove special characters from string by use Substitute function by peoplecode

For example 1  is create function remove special

Function RemoveSpecial(&Textdescr)

&Textdescr = Substitute(&Textdescr, “*”, “”);
&Textdescr = Substitute(&Textdescr, “^”, “”);
&Textdescr = Substitute(&Textdescr, “~”, “”);
&Textdescr = Substitute(&Textdescr, “|”, “”);
&Textdescr = Substitute(&Textdescr, “&”, “”);
&Textdescr = Substitute(&Textdescr, “>”, “”);
&Textdescr = Substitute(&Textdescr, “<“, “”);

&Textdescr = Substitute(&Textdescr, “.”, “”);
&Textdescr = Substitute(&Textdescr, “-“, “”);

/*– more statment –*/

End-Function;

For example 2: You create peoplecode at action saveprechang or savepostchange

SQLExec("UPDATE PS_TESTS SET KTB_DESCR1 = REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(TEST_DESCR1, CHR(10), ''), CHR(13), '') , CHR(09), ''),'""',''),' ','') WHERE TEST_SIC_YEAR= :1 AND EMPLID = :2 AND TEST_SIC_GRP = :3 and TEST_INT_RC= :4", TEST_EMP_RANK.TEST_SIC_YEAR, TEST.EMPLID, TEST.TEST_SIC_GRP, TEST.TEST_INT_RC);

How to use MsgGet, MsgGetText and MsgGetExplainText by Peoplecode Function of Peoplesoft

How to use MsgGet, MsgGetText and MsgGetExplainText by Peoplecode Function of Peoplesoft

MsgGet syntax

MsgGet(message_set, message_num, default_msg_txt[, paramlist])

Example: &MsgText = MsgGet(30000, 2, “Message not found”);

MsgGetText syntax

MsgGetText(message_set, message_num, default_msg_txt[, paramlist])
Example: &MsgText = MsgGetText(30000, 2, “Message not found”);

 

MsgGetExplainText(message_set, message_num, default_msg_txt[, paramlist])

Example1

If Message Catalog (100,1)= This is my name is %1 and i like pet is %2.

&paramlist1= “Joy”;

&paramlist2= “cat”;

MsgGetExplainText(100, 1, “Message not found”, paramlist1,&paramlist2)

Result= This is my name is Joy and i like pet is cat.

 

Example2

Define Message catalog : 

message_set =20005 

message_num= 4

Severity = Message

Message Text = Test Mail

Description = Email Tracking Coaching & Performance

 

Example of use each function

&MsgGet = MsgGet(20005, 4, “default_msg_txt”);

&MsgGet=Test Mail (20005,4)

&MsgGetText = MsgGetText(20005, 4, “default_msg_txt”);

&MsgGetText=Test Mail 

&MsgGetExplainText = MsgGetExplainText(20005, 4, “default_msg_txt”);

&MsgGetExplainText=Email Tracking Coaching & Performance

WinMessage(“&MsgGet=” | &MsgGet);
WinMessage(“&MsgGetText=” | &MsgGetText);
WinMessage(“&MsgGetExplainText=” | &MsgGetExplainText);

 

 

 

How to use Winmessage in Peoplecode

How to use Winmessage in Peoplecode

&RESULT = WinMessage(“Please Confirm ” | Char(13) | Char(10) | ” Yes = Confirm ” | Char(13) | Char(10) | “No = Exit”, 4);

If &RESULT = %MsgResult_Yes Then
/* Yes button was pressed — do Yes button stuff */

else
/* No button was pressed — do No button stuff */

end-if;

Syntax : WinMessage(message [, ​style] [, ​title])

Message : Text displayed in message box. Normally you want to use the MsgGet or MsgGetText function to retrieve the message from the Message Catalog.

Title : Title of message box.

Style : Either a numerical value or a constant specifying the contents and behavior of the dialog box. This parameter is calculated by cumulatively adding either a value or a constant from each of the following categories

Category Value Constant Meaning
Buttons 0 %MsgStyle_OK The message box contains one pushbutton: OK.
1 %MsgStyle_OKCancel The message box contains two pushbuttons: OK and Cancel.
2 %MsgStyle_AbortRetryIgnore The message box contains three pushbuttons: Abort, Retry, and Ignore.
3 %MsgStyle_YesNoCancel The message box contains three pushbuttons: Yes, No, and Cancel.
4 %MsgStyle_YesNo The message box contains two push buttons: Yes and No.
5 %MsgStyle_RetryCancel The message box contains two push buttons: Retry and Cancel.
Value Constant Meaning
-1 %MsgResult_Warning Warning was generated.
1 %MsgResult_OK OK button was selected.
2 %MsgResult_Cancel Cancel button was selected.
3 %MsgResult_Abort Abort button was selected.
4 %MsgResult_Retry Retry button was selected.
5 %MsgResult_Ignore Ignore button was selected.
6 %MsgResult_Yes Yes button was selected.
7 %MsgResult_No No button was selected.

How to use Dynamic Variable Names in PeopleCode

How to use Dynamic Variable Names in PeopleCode

  • Record name dynamically by peoplecode

&RECNAME = “JOB”;
&RECNAME = “RECORD.” | Upper(&RECNAME);

Local Record &rec = CreateRecord(@&RECNAME);

 

  • Field name dynamically by peoplecode

&MesssgevalueName = “&ValueFieldName”| “1”;
WinMessage(@(&MesssgevalueName),0);

 

  • Record and Field name dynamically by peoplecode

Local Field &FieldName;
Local Record &REC;

&REC = CreateRecord(Record.TEST_TBL);

For &RW= 1 To &rec.activerowcount

&REC.GetField(@(“Field.” | “STATUS” | String(&RW)).Value = &RW;

end-for;

How to Generate xml file using Peoplecode

How to Generate xml file using Peoplecode

You can create xml file by peoplecode

How to Generate xml file using Peoplecode

1. Create xml file by peoplecode then print data in message and copay data and save as xml file

 import PSXP_XMLGEN:*;
/* You can also use XMLDoc class to create xml files from peoplecode. Here is a simple example. This creates an xml file with the contents of a table.
*/

Local XmlDoc &inXMLDoc;
Local XmlNode &rootNode, &childNode1, &childNode2, &textNode2;
Local string &xmlStr;
Local File &xmlFile;
Local number &i;

&file_name = “/Your Path/appserv/UAT/TESTXML.xml”;
&xmlFile = GetFile(&file_name, “W”, %FilePath_Absolute); /* Code to initialize the file object */

&inXMLDoc = CreateXmlDoc(“”);
&rootNode = &inXMLDoc.CreateDocumentElement(“root”);

Local Record &rec = CreateRecord(Record.TEST);
Local SQL &sql = CreateSQL(“SELECT * FROM PS_TEST “);

While &sql.Fetch(&rec)
&childNode1 = &rootNode.AddElement(Lower(&rec.Name));
For &i = 1 To &rec.FieldCount
&childNode2 = &childNode1.AddElement(Lower(&rec.GetField(&i).Name));
&textNode2 = &childNode2.AddText(&rec.GetField(&i).Value);
End-For;
End-While;

&xmlStr = &inXMLDoc.GenFormattedXmlString();

&xmlFile.WriteLine(&xmlStr);

&xmlFile.Close();
WinMessage(&xmlStr, 0);

2. Create xml file by peoplecode then write file xml to app server

You can use field change event or other event.

import PSXP_XMLGEN:*;
/* You can also use XMLDoc class to create xml files from peoplecode. Here is a simple example. This creates an xml file with the contents of a table. */

Local XmlDoc &inXMLDoc;
Local XmlNode &rootNode, &childNode1, &childNode2, &textNode2;
Local string &xmlStr;
Local File &xmlFile;
Local number &i;

&inXMLDoc = CreateXmlDoc(“”);
&rootNode = &inXMLDoc.CreateDocumentElement(“root”);

Local Record &rec = CreateRecord(Record.TEST);
Local SQL &sql = CreateSQL(“SELECT * FROM PS_TEST “);

While &sql.Fetch(&rec)
&childNode1 = &rootNode.AddElement(Lower(&rec.Name));
For &i = 1 To &rec.FieldCount
&childNode2 = &childNode1.AddElement(Lower(&rec.GetField(&i).Name));
&textNode2 = &childNode2.AddText(&rec.GetField(&i).Value);
End-For;
End-While;

&xmlStr = &inXMLDoc.GenFormattedXmlString();
WinMessage(&xmlStr, 0);

How to Send HTML Mail by Peoplecode of Peoplesoft

How to Send HTML Mail by Peoplecode of Peoplesoft

You can use send html email by peoplecode use sendmail function

&MAIL_FLAGS = 0;
&MAIL_CC = “”;
&MAIL_BCC = “”;
&MAIL_SUBJECT = “”;
&MAIL_TEXT = “”;
&MAIL_FILES = “”;
&MAIL_TITLES = “”;
&MAIL_SENDER = “Test@mail.com”;
&MAIL_SUBJECT = &Subject_mail;
&MAIL_TEXT = &Content_Mail;

&CONTTYPE = “Content-type: text/html; charset=utf8”;
&MAIL_SEP = “;”;

&RET = SendMail(&MAIL_FLAGS, &MAIL_TO, &MAIL_CC, &MAIL_BCC, &MAIL_SUBJECT, &MAIL_TEXT, &MAIL_FILES, &MAIL_TITLES, &MAIL_SENDER, &MAIL_SEP, &CONTTYPE);

How to Send Mail By Peoplecode of Peoplesoft

How to Send Mail By Peoplecode of Peoplesoft

You can send e-mail by peoplecode  with sendmail function

&MAIL_FLAGS = 0;
&MAIL_CC = “”;
&MAIL_BCC = “”;
&MAIL_SUBJECT = “”;
&MAIL_TEXT = “”;
&MAIL_FILES = “”;
&MAIL_TITLES = “”;
&MAIL_SENDER = “Test@mail.com”;
&MAIL_SUBJECT = &Subject_mail;
&MAIL_TEXT = &Content_Mail;

&RET = SendMail(&MAIL_FLAGS, &MAIL_TO, &MAIL_CC, &MAIL_BCC, &MAIL_SUBJECT, &MAIL_TEXT, &MAIL_FILES, &MAIL_TITLES, &MAIL_SENDER);