Find SendMail Peoplecode

479 views Asked by At

We have custom functionality in PeopleSoft FSCM that generates an email notification with a link to direct users to approve vouchers online. I have found part of the text string variable that compose the email message within the following Record PeopleCode, however I can not seem to find where the actual outbound email object is created and Send method is being called and using the &EMAIL_TEXT variable. I've done Find In searches for the variable but that has not led me to the code that generates the emails. Any suggestions for how to find it is appreciated!

Here is the code snippet with the email body variable:

&EMAIL_TEXT = "Please review and take approval action for the following:" | Char(10) | "Business Unit: " | VCHR_APPRVL.BUSINESS_UNIT.Value | Char(10) | "Voucher ID: " | VCHR_APPRVL.VOUCHER_ID | Char(10) | Char(10) | Char(10);
   &EMAIL_TEXT = &EMAIL_TEXT | "The following hyperlink will take you to the voucher approval page:" | Char(10);
   &URL = GenerateComponentPortalURL("EMPLOYEE", Node.ERP, MenuName.ENTER_VOUCHER_INFORMATION, "GBL", Component.VCHR_APPROVE, Page.VCHR_APPRVL_WF, "U", VCHR_APPRVL.BUSINESS_UNIT, VCHR_APPRVL.VOUCHER_ID);
   &EMAIL_TEXT = &EMAIL_TEXT | &URL | Char(10);

   &EMAIL_TEXT = &EMAIL_TEXT | Char(10) | Char(10);
   &EMAIL_TEXT = &EMAIL_TEXT | "Questions pertaining to this data should be directed to [email protected]" | Char(10);
   &EMAIL_TEXT = &EMAIL_TEXT | Char(10) | Char(10);
   &EMAIL_TEXT = &EMAIL_TEXT | "****DO NOT REPLY TO THIS EMAIL AS THIS ACCOUNT IS NOT MONITORED****" | Char(10);
   &EMAIL_TEXT = &EMAIL_TEXT | Char(10) | Char(10);
   GH_VCHR_APR_WRK.EMAILTEXT.Value = &EMAIL_TEXT;

Here is the entire Record PeopleCode (for context) on the field BUSPROCNAME with the SaveEdit action:

Declare Function virtual_approver PeopleCode APPR_VA0_WRK.FUNCLIB_01 FieldFormula;
Declare Function get_roleuser PeopleCode APPR_VA0_WRK.ROLEUSER FieldChange;
Declare Function get_message_text PeopleCode WF_FUNCLIB_WRK.FUNCLIB_01 FieldFormula;

Component boolean &overrideapprover;

Function get_denial_role();
   &SETID = GetSetId(Field.BUSINESS_UNIT, VCHR_APPRVL.BUSINESS_UNIT, Record.BUS_UNIT_OPT_AP, "");
   &CURRDATE = %Date;
   SQLExec("Select a.rolename from ps_bus_unit_opt_ap a where a.setid = :1 and a.effdt = (Select max(b.effdt) from ps_bus_unit_opt_ap b where b.setid = :2 and b.effdt <= %datein(:3) and b.eff_status = 'A')", &SETID, &SETID, &CURRDATE, APPR_FIELDS_WRK.ROLENAME);
End-Function;

Function get_deptid(&BU, &Voucher_ID, &Dept_Cnt, &DEPTID);
   Local SQL &SQL_DEPTID;
   &Dept_Cnt = 0;
   /* If &VOUCHER_STYLE = "JRNL" Or
         &VOUCHER_STYLE = "CORR" Or
         &VOUCHER_STYLE = "ADJ" Then
      MessageBox(0, "", 0, 0, "Jrnl or Adj or Reversal. So assigning 99999", 0);
      &DEPTID = "99999";
      &Dept_Cnt = 1;
   Else */
   SQLExec("SELECT DEPTID FROM PS_GH_VCHAPPR_DEPT WHERE BUSINESS_UNIT = :1 AND VOUCHER_ID = :2", &BU, &Voucher_ID, &DEPTID);
   If All(&DEPTID) Then
      &Dept_Cnt = 1;
   Else
      &SQL_DEPTID = CreateSQL("SELECT DISTINCT DEPTID FROM PS_DISTRIB_LINE A, PS_PO_LINE B WHERE A.BUSINESS_UNIT = :1 AND VOUCHER_ID = :2 AND A.BUSINESS_UNIT_PO = B.BUSINESS_UNIT AND A.PO_ID = B.PO_ID AND A.LINE_NBR = B.LINE_NBR AND B.RECV_REQ <> 'Y'", &BU, &Voucher_ID);
      While &SQL_DEPTID.Fetch(&DEPTID_Fetch)
         &Dept_Cnt = &Dept_Cnt + 1;
         &DEPTID = &DEPTID_Fetch;
      End-While;
   End-If;
   rem End-If; 
End-Function;


/* ---------------- beginning of mainline --------------------------*/
/* ICE 597971000 - TMG - 06/17/03 */
/* Check if nothing has changed on the approval status */
If Not FieldChanged(VCHR_APPRVL.APPR_STATUS) Then
   Error MsgGet(7045, 5, "The approval status has not been changed/updated, page cannot be saved until the approval status has been modified.!");
End-If;

If VCHR_APPRVL.APPR_STATUS = "D" And
      VCHR_FS.APPR_INSTANCE = 0 Then
   Error MsgGet(7045, 7, "The voucher cannot be Denied  until it has been routed.");
End-If;


/* ICE 531713000 - TMG - 12/13/02 */
/* Check if voucher status has changed */

rem SQLExec("SELECT ENTRY_STATUS, CLOSE_STATUS, PROCESS_MAN_CLOSE FROM PS_VOUCHER WHERE BUSINESS_UNIT = :1 AND VOUCHER_ID = :2", VCHR_APPRVL.BUSINESS_UNIT, VCHR_APPRVL.VOUCHER_ID, &ENTRY_STATUS, &CLOSE_STATUS, &PROCESS_MAN_CLOSE);
SQLExec("SELECT ENTRY_STATUS, CLOSE_STATUS, PROCESS_MAN_CLOSE, VOUCHER_STYLE FROM PS_VOUCHER WHERE BUSINESS_UNIT = :1 AND VOUCHER_ID = :2", VCHR_APPRVL.BUSINESS_UNIT, VCHR_APPRVL.VOUCHER_ID, &ENTRY_STATUS, &CLOSE_STATUS, &PROCESS_MAN_CLOSE, &VOUCHER_STYLE);

If &ENTRY_STATUS = "P" And
      &CLOSE_STATUS <> "C" And
      &PROCESS_MAN_CLOSE <> "Y" Then

   /* Check if worklist item has been cancelled */
   &INSTANCEID = %WLInstanceId;
   If All(&INSTANCEID) Then
      SQLExec("SELECT MAX(A.ACTIVITYNAME), MAX(A.EVENTNAME), MAX(A.WORKLISTNAME) FROM PS_VCHR_WL1 A, PSWORKLIST B WHERE A.BUSPROCNAME = B.BUSPROCNAME AND A.ACTIVITYNAME = B.ACTIVITYNAME AND A.EVENTNAME = B.EVENTNAME AND A.WORKLISTNAME = B.WORKLISTNAME AND A.INSTANCEID = B.INSTANCEID AND A.BUSPROCNAME = :1 AND A.BUSINESS_UNIT = :2 AND A.VOUCHER_ID = :3 AND A.INSTANCEID = :4", VCHR_APPRVL.BUSPROCNAME, VCHR_APPRVL.BUSINESS_UNIT, VCHR_APPRVL.VOUCHER_ID, &INSTANCEID, &ACTIVITYNAME, &EVENTNAME, &WORKLISTNAME);

      SQLExec("SELECT INSTSTATUS FROM PSWORKLIST WHERE BUSPROCNAME = :1 AND ACTIVITYNAME = :2 AND EVENTNAME = :3 AND WORKLISTNAME = :4 AND INSTANCEID = :5", VCHR_APPRVL.BUSPROCNAME, &ACTIVITYNAME, &EVENTNAME, &WORKLISTNAME, &INSTANCEID, &INSTSTATUS);

      If &INSTSTATUS = 3 Then
         Error MsgGet(7045, 4, "Voucher approval status cannot be changed because worklist item has been cancelled.")
      End-If;
   End-If;
Else
   Error MsgGet(7045, 3, "Voucher approval status cannot be changed because voucher status has changed.");
End-If;

/* If (APPR_STATUS = "A" And
      %MessageAgent = "") Or
      (APPR_STATUS = "P" And
         %MessageAgent <> "") Then */
If VCHR_APPRVL.APPR_STATUS = "A" And
      %CompIntfcName <> "" Or
      VCHR_APPRVL.APPR_STATUS = "D" Then
   If &overrideapprover = True Then
      rem &OPRID = ""; /*custom commented this line and added the next*/
      &OPRID = VCHR_FS.OPRID;
   Else
      &OPRID = %OperatorId;
   End-If;
   get_roleuser(&OPRID, &EMAILID, &FORMID, &EMPLID, &ROLEUSER);
   rem the following four fields are required;
   APPR_FIELDS_WRK.BUSPROCNAME = VCHR_APPRVL.BUSPROCNAME;
   APPR_FIELDS_WRK.APPR_RULE_SET = VCHR_APPRVL.APPR_RULE_SET;
   APPR_FIELDS_WRK.ROLEUSER = &ROLEUSER;
   APPR_FIELDS_WRK.APPR_INSTANCE = VCHR_APPRVL.APPR_INSTANCE;
   SQLExec("SELECT GH_BUSINESS_UNIT_O FROM PS_GH_VCHAPPR_DEPT WHERE BUSINESS_UNIT = :1 AND VOUCHER_ID = :2", &BU, &Voucher_ID, &GH_BUSINESS_UNIT_O); */
   SQLExec("SELECT GH_BUSINESS_UNIT_O FROM PS_GH_VCHAPPR_DEPT WHERE BUSINESS_UNIT = :1 AND VOUCHER_ID = :2", VCHR_APPRVL.BUSINESS_UNIT, VCHR_APPRVL.VOUCHER_ID, &GH_BUSINESS_UNIT_O);
   VCHR_APPRVL_WRK.GH_BUSINESS_UNIT_O.Value = &GH_BUSINESS_UNIT_O;
   get_deptid(VCHR_APPRVL.BUSINESS_UNIT, VCHR_APPRVL.VOUCHER_ID, &Dept_Cnt, &DEPTID);

   &EMAIL_TEXT = "Please review and take approval action for the following:" | Char(10) | "Business Unit: " | VCHR_APPRVL.BUSINESS_UNIT.Value | Char(10) | "Voucher ID: " | VCHR_APPRVL.VOUCHER_ID | Char(10) | Char(10) | Char(10);
   &EMAIL_TEXT = &EMAIL_TEXT | "The following hyperlink will take you to the voucher approval page:" | Char(10);
   &URL = GenerateComponentPortalURL("EMPLOYEE", Node.ERP, MenuName.ENTER_VOUCHER_INFORMATION, "GBL", Component.VCHR_APPROVE, Page.VCHR_APPRVL_WF, "U", VCHR_APPRVL.BUSINESS_UNIT, VCHR_APPRVL.VOUCHER_ID);
   &EMAIL_TEXT = &EMAIL_TEXT | &URL | Char(10);

   &EMAIL_TEXT = &EMAIL_TEXT | Char(10) | Char(10);
   &EMAIL_TEXT = &EMAIL_TEXT | "Questions pertaining to this data should be directed to [email protected]" | Char(10);
   &EMAIL_TEXT = &EMAIL_TEXT | Char(10) | Char(10);
   &EMAIL_TEXT = &EMAIL_TEXT | "****DO NOT REPLY TO THIS EMAIL AS THIS ACCOUNT IS NOT MONITORED****" | Char(10);
   &EMAIL_TEXT = &EMAIL_TEXT | Char(10) | Char(10);
   GH_VCHR_APR_WRK.EMAILTEXT.Value = &EMAIL_TEXT;

   If None(&DEPTID) Then
      REM VCHR_APPRVL_WRK.DEPTID.Value = "99999";
      MessageBox(0, "", 0, 0, "No Deptid. So assigning 99999", 0);
      VCHR_APPRVL_WRK.DEPTID.Value = "99999";
   Else
      VCHR_APPRVL_WRK.DEPTID.Value = &DEPTID;
   End-If;
   If VCHR_APPRVL.APPR_STATUS = "D" Then
      APPR_FIELDS_WRK.APPR_ACTION = "D";
   Else
      APPR_FIELDS_WRK.APPR_ACTION = "A";
   End-If;
   If VCHR_APPRVL.APPR_STATUS = "A" Then
      VCHR_APPRVL.APPR_STATUS = "P";
   End-If;
   virtual_approver();
   If &overrideapprover = True Then
      &overrideapprover = False;
   End-If;
   VCHR_APPRVL.APPR_CHECK_FLG = "Y";
   rem;
   VCHR_APPRVL.APPR_STATUS = APPR_FIELDS_WRK.APPR_STATUS;
   remark set up the message for e-mail if denied;
   If VCHR_APPRVL.APPR_STATUS = "D" Then
      &LANGUAGE_CD = PSOPTIONS.LANGUAGE_CD;
      &MESSAGE_SET_NBR = 7045;
      &MESSAGE_NBR = 2;
      &BIND1 = VCHR_FS.BUSINESS_UNIT | "/" | VCHR_FS.VOUCHER_ID;
      &BIND2 = APPR_FIELDS_WRK.ROLEUSER;
      &BIND3 = VCHR_FS.VENDOR_ID | ", " | VENDOR.NAME1;
      &BIND4 = VCHR_FS.INVOICE_ID | " (" | VCHR_FS.INVOICE_DT | ")";
      &BIND5 = VCHR_FS.GROSS_AMT | "(" | VCHR_FS.TXN_CURRENCY_CD | ")";
      get_message_text(&MESSAGE_SET_NBR, &MESSAGE_NBR, &BIND1, &BIND2, &BIND3, &BIND4, &BIND5, &MESSAGE_TEXT, &DESCRLONG);
      UpdateValue(VCHR_APPRVL_MSG.EMAIL_SUBJECT_LONG, 1, &DESCRLONG);
      UpdateValue(VCHR_APPRVL_MSG.EMAIL_TEXTLONG, 1, &MESSAGE_TEXT);
      remark get the role to send denials to;
      get_denial_role();
      VCHR_APPRVL_WRK.RTE_CNTL_TYPE1 = "Business Unit";
      VCHR_APPRVL_WRK.RTE_CNTL_TYPE2 = "Administrative Area";
      VCHR_APPRVL_WRK.WF_ADMIN_AREA = "AP";
      VCHR_APPRVL_WRK.ROLENAME = APPR_FIELDS_WRK.ROLENAME;
   End-If;
End-If;
1

There are 1 answers

5
Based On BEST ANSWER

The email text is being saved into a work record field, so the sendmail call doesn't have to be in this event. (It isn't in the code you provided)

In the Component Processor Flow, after SaveEdit there's SavePreChange, Workflow and SavePostChange, but since it is saved in a work record, it's also possible that additional user input is required after the Save Processing flow and therefor it could literally be anywhere.