Here is the core code to a function that will dynamically generate a URL to a page in PeopleSoft (page specified by you). The email body uses a message catalog entry for formatting. The Send From email address is dynamic to the environment - so the environment that sends the email is identifiable without opening it up.
Hope this helps someone.
import PT_MCF_MAIL:MCFOutboundEmail;
Local PT_MCF_MAIL:MCFOutboundEmail &ObjectEmail = create PT_MCF_MAIL:MCFOutboundEmail();
Local Rowset &rsEmailBody;Local string &sEmplId, &sEmailAddress, &URI, &URL, &keyList, &dbName;
/* Generate a URL for the user to access their Time Sheet *//* Use parameters passed to function to build Key List */&keyList = "&TIME_SHEET_ID=" | &sTimeSheetId | "&VERSION_NUM=" | &nVersionNum | "&EMPLID=" | &sEmplId | "&PERIOD_END_DT=" | &dPeriodEndDate;
/* Use GenerateComponentPortalURL function to make URL dynamic the environment you are in */&URI = GenerateComponentPortalURL(%Portal, %Node, MenuName.ADMINISTER_EXPENSE_FUNCTIONS, %Market, Component.TE_TIME_ENTRY, "", "U");&URL = &URI | &keyList;
/* Get data for message body */&rsEmailBody = CreateRowset(Record.EX_TIME_AW);&rsEmailBody.Fill("WHERE APPROVAL_OPRID = :1 AND TRANSACTION_ID = :2 AND VERSION_NUM = :3", %OperatorId, &sTimeSheetId, &nVersionNum);
/* Workflow email reply address is should be dynamic *//* Use %DBName meta variable to capture the environment name */&dbName = %DbName;
/*-- Initialize the usual fields of an email --*/&ObjectEmail.From = "workflow_" | Lower(&dbName) | "@company.com";&ObjectEmail.Recipients = &sEmailAddress;&ObjectEmail.Subject = MsgGetText(20000, 166, "", &sTimeSheetId);&ObjectEmail.Text = MsgGetExplainText(20000, 166, "", &sEmplId, &rsEmailBody(1).EX_TIME_AW.GetField(Field.NAME).Value, &rsEmailBody(1).EX_TIME_AW.SUBMISSION_DATE.Value, &rsEmailBody(1).EX_TIME_AW.PERIOD_END_DT.Value, &sTimeSheetId, &nVersionNum, &rsEmailBody(1).EX_TIME_AW.DTL_TOTAL.Value, &rsEmailBody(1).EX_TIME_AW.POL_TOTAL.Value, &URL);
/* Send Email */Local integer &resp = &ObjectEmail.Send();
/* Verify Email was properly sent */Evaluate &respWhen %ObEmail_Delivered/* every thing ok */&done = True;Break;When %ObEmail_NotDelivered/*-- Check &email.InvalidAddresses, &email.ValidSentAddresses and &email.ValidUnsentAddresses */&done = False;Break;When %ObEmail_PartiallyDelivered/* Check &email.InvalidAddresses, &email.ValidSentAddresses and &email.ValidUnsentAddresses; */&done = True;Break;When %ObEmail_FailedBeforeSending/* Get the Message Set Number, message number; Or just get the formatted messages from &email.ErrorDescription, &email.ErrorDetails;*/&done = False;Break;End-Evaluate;
No comments:
Post a Comment