Showing posts with label peoplecode. Show all posts
Showing posts with label peoplecode. Show all posts

SendMail – Sending Email in Peoplecode

---SendMail – Sending Email through peoplecode send mail function


Local string &NL = "<br>"; /* The new line character in html */
 
/* Setting the parameters for sendmail */
&MAIL_FLAGS = 0;
&MAIL_TO = "bharat@search.com";
/* &MAIL_CC = "email2@psoftsearch.com";
&MAIL_BCC = "email3@psoftsearch.com"; */
&MAIL_SUBJECT = "Test Email";
&MAIL_FILES = "";
&MAIL_TITLES = "";
 
/* Getting page field values */
&f_name = R9_EMP_NAME.FNAME.Value;
&l_name = R9_EMP_NAME.LNAME.Value;
 
/* Making the email body */
&MAIL_GREET = "<font face ='Arial'>Dear " | &f_name | " " | &l_name | "," | &NL | &NL;
&MAIL_TEXT1 = "This is a test email that contains an HTML table." | &NL |  &NL;
&MAIL_TEXT2 = "<table border='1'><tr bgcolor = '#AAAAAA' ><th>Name</th><th>State</th><th>Country</th></tr><tr><td>Rojer Alex</td><td>VA</td><td>USA</td></tr></table>" | &NL;
&TEXT1 = "Your footer line(s) goes here." | &NL | &NL;
&TEXT2 = "Regards," | &NL | "The PSoftSearch team";
&MAIL_FOOTER = &TEXT1 | &TEXT2 | "</font>";
&MAIL_TEXT_BODY = &MAIL_GREET | &MAIL_TEXT1 | &MAIL_TEXT2 | &MAIL_FOOTER;
 
/* Sending the email */
&RET_CODE = SendMail(&MAIL_FLAGS, &MAIL_TO, &MAIL_CC, &MAIL_BCC, &MAIL_SUBJECT, &MAIL_TEXT_BODY, &MAIL_FILES, &MAIL_TITLES, "", ";", "Content-type: text/html; charset=utf8");
 
/* Evaluating the return value of sendmail and showing the appropriate message */
If (&RET_CODE = 0) Then
MessageBox(0, "Alert", 0, 0, "Email has been sent.");
Else
MessageBox(0, "Alert", 0, 0, "Unable to send email.");
End-If;

Sending Mails using Generic Templates



Send Mail using Generic Templates


import PT_WF_NOTIFICATION:NotificationAddress;
import PT_WF_NOTIFICATION:Notification;
import PT_WF_NOTIFICATION:NotificationTemplate;
import PT_MCF_MAIL:*;
import PT_MCF_MAIL:MCFOutboundEmail;
import PT_MCF_MAIL:MCFEmail;

Local array of string &aryValues;
Local array of PT_WF_NOTIFICATION:NotificationAddress &mynotifyto;
Local PT_WF_NOTIFICATION:NotificationAddress &mynotifyaddress;
Local PT_WF_NOTIFICATION:Notification &mynotification;
Local string &emailid, &Template_Name;


/* Email Applicant START*/
&mynotifyto = CreateArrayRept(&mynotifyaddress, 0);
SQLExec("select EMAIL_ADDR from PS_EMAIL_ADDRESSES where EMPLID=:1 AND PREF_EMAIL_FLAG='Y' AND E_ADDR_TYPE='CAMP'", N_SR_EXT016_VW.EMPLID.Value, &emailid);
&mynotifyaddress = create PT_WF_NOTIFICATION:NotificationAddress("", "", "", &emailid, "Email");
If All(&emailid) Then
   &mynotifyto.Push(&mynotifyaddress);
   &Template_Name = "N_STDNT_AWARD";
   &mynotifytemplate = create PT_WF_NOTIFICATION:NotificationTemplate("", "", &Template_Name, "G");
   
   /* Populate an array to contain the values needed by the template */
   &aryValues = CreateArrayRept("", 0);
   
   &aryValues.Push(&EmplName);
   &aryValues.Push(&CalcBrndDescr);
   &aryValues.Push(&CalcMdlDescr);
   &aryValues.Push(&Effdt);
   
   &xmlVars = &mynotifytemplate.SetupGenericVars(&aryValues);
   &mynotifytemplate.GetAndExpandTemplate(%Language, &xmlVars);
   &mynotification = create PT_WF_NOTIFICATION:Notification(" ", %Date + %PerfTime, %Language);
   
   &mynotification.NotifyTo = &mynotifyto;
   &mynotification.ContentType = "Content-type: text/html; charset=US-ASCII";
   &mynotification.Subject = &mynotifytemplate.Subject;
   &mynotification.Message = &mynotifytemplate.Text;
   &mynotification.Send();
End-If;

Working with flat files in peoplesoft

Working with flat files in peoplesoft



1) Using Filelayout
2) Using Array

Using Array:

Declare Function ClearData PeopleCode N_SR_RUNCNTL.N_SELECTION_TYPE FieldFormula;

Declare Function add_attachment PeopleCode N_SR_ATTACH_WRK.ATTACHADD FieldChange;
Declare Function display_attachment_buttons PeopleCode N_SR_ATTACH_WRK.ATTACHADD RowInit;
Local number &CurRow, &RETCODE;
Local string &Guid, &URL_ID;
Local Rowset &RS1, &Rs_Std;
Local Rowset &Level1;

rem local record &RS1;


/****************************************************************/
/* Call the correct database record where your file attachment  */
/*    will be stored 

N_MOODLE_INTFC_R2_ATTACH                                           */
/****************************************************************/
&URL_ID = "URL.N_MOODLE_INTFC_R2_ATTACH"; /************************ */
/* In order to make sure the attachmentname is unique           */
/*     you can add a GUID in front of your File name            */
/*************************************************************** */


&Level1 = GetLevel0()(1).GetRowset(Scroll.N_NINT09_R2_TMP);
&Level1.Flush();

add_attachment(@&URL_ID, "", &Guid, 0, True, "Record.N_NINT09_R2_RC", N_NINT09_R2_RC.ATTACHSYSFILENAME, N_NINT09_R2_RC.ATTACHUSERFILE, 2, &RETCODE);
If &RETCODE = %Attachment_Success Then
   rem display_attachment_buttons("Success");
   
   &filepath = GetCwd();
   &InputfileName = N_NINT09_R2_RC.ATTACHSYSFILENAME.Value;
   &M = GetAttachment(URL.N_MOODLE_INTFC_R2_ATTACH, &InputfileName, &filepath | &InputfileName);
   &N_File_Input = GetFile(&filepath | &InputfileName, "r", "a", %FilePath_Absolute);
   &N_File_Input.SetFileLayout(FileLayout.N_SR_NINT09_FL);
   rem &RS1 = CreateRecord(RECORD.N_NINT09_R2_TMP);
   
   &num = 0;
   &RS1 = &N_File_Input.CreateRowset();
   &RS1 = &N_File_Input.ReadRowset();
   &RS1 = &N_File_Input.ReadRowset();
   rem ClearData();
   /*************************START READING FROM INPUT FILE**************************************/
   While &RS1 <> Null;
      /*****************************INSERT INTO TEMPORARY RECORD*********************************/
      
      &Row = &Level1.ActiveRowCount;
      &Level1.InsertRow(&Row);
      rem MessageBox(0, "", 0, 0, "Row :" | &Row);
      rem MessageBox(0, "", 0, 0, "Runc Cntl :" | N_NINT09_R2_RC.RUN_CNTL_ID.Value);
      rem MessageBox(0, "", 0, 0, "Emplid :" | &RS1(1).GetRecord(1).EMPLID.Value);
      
      &Level1(&Row + 1).N_NINT09_R2_TMP.OPRID.Value = %OperatorId;
      &Level1(&Row + 1).N_NINT09_R2_TMP.RUN_CNTL_ID.Value = N_NINT09_R2_RC.RUN_CNTL_ID.Value;
      &Level1(&Row + 1).N_NINT09_R2_TMP.EMPLID.Value = &RS1(1).GetRecord(1).EMPLID.Value;
      &Level1(&Row + 1).N_NINT09_R2_TMP.STRM.Value = &RS1(1).GetRecord(1).STRM.Value;
      &Level1(&Row + 1).N_NINT09_R2_TMP.CLASS_NBR.Value = &RS1(1).GetRecord(1).CLASS_NBR.Value;
      &Level1(&Row + 1).N_NINT09_R2_TMP.CRSE_GRADE_INPUT.Value = &RS1(1).GetRecord(1).CRSE_GRADE_INPUT.Value;
      
      &RS1 = &N_File_Input.ReadRowset();
   End-While; /*Read Lines inside a file*/
   
   For &I = &Level1.ActiveRowCount To 1 Step - 1
      If None(&Level1.GetRow(&I).N_NINT09_R2_TMP.OPRID.Value) Then
         &Level1.DeleteRow(&I);
      End-If;
   End-For;
   
   &N_File_Input.Close();
Else
   N_NINT09_R2_RC.ATTACHUSERFILE.Value = "";
End-If;

Basics of Component Interface (CI)


Basics of Component Interface (CI)

CI enables exposure of a component for synchronous assess from another application like, peoplecode, Java, C/C++, XML.

CI executes the business logic into the component and as a result, they provide a higher level of data validation than a simple SQL insert.

In a simple SQL insert, a row is inserted in database without checking for validation.

One CI maps to only one component. But one component can have more than 1 CIs.

Executing business logic mean by using CI we can trigger all checks for validating the fields i.e  checks on field edit, save edit, save pre change, workflow & save post change

Methods used to create, find, modify or delete data.

Pre-requisite of Excel to CI utility.



Characteristics of CI

A CI maps to one and only one component.

CIs are created in Application Designer

Record Fields on the component are mapped to the keys and properties of the CI.


Methods are used to find, create, modify or delete data.


Attributes of CI
Name
Keys
Properties and Collections
Methods


Component Interface Methods

There are five standard methods which comes while creating CI.

Here is a list of standard methods

Cancel
Create
Find
Get
Save
GetPropertyByName
SetPropertyByName
GetPropertyInfoByName – CompIntfPropInfoCollection