Skip to content

Instantly share code, notes, and snippets.

@jvanhoesen
Created November 24, 2020 21:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jvanhoesen/030ee7529c1bd8aa45da04166cfc059a to your computer and use it in GitHub Desktop.
Save jvanhoesen/030ee7529c1bd8aa45da04166cfc059a to your computer and use it in GitHub Desktop.
EPApproval RowInserting Additional Information
/// <summary>
/// Set additional information on the approval record for the approver
/// </summary>
protected virtual void _(Events.RowInserting<EPApproval> e)
{
if (e.Row is EPApproval)
{
AATimeRequest currentTR = Document.Current;
if (currentTR != null)
{
e.Cache.SetValue<EPApproval.refNoteID>(e.Row, currentTR.NoteID);
EPEmployee employee = PXSelect<EPEmployee, Where<EPEmployee.bAccountID, Equal<Required<EPEmployee.bAccountID>>>>.Select(this, currentTR.EmployeeID);
if (employee != null)
{
e.Cache.SetValue<EPApproval.documentOwnerID>(e.Row, employee.UserID);
e.Cache.SetValue<EPApproval.bAccountID>(e.Row, employee.BAccountID);
}
e.Cache.SetValue<EPApproval.docDate>(e.Row, currentTR.Date);
e.Cache.SetValue<EPApproval.descr>(e.Row, currentTR.Description);
string details = "";
foreach(AATimeRequestDetail detail in Details.Select())
{
details += string.Format(AdvancedTimeCardMessages.TRApprovalDetails, detail.Date.Value.ToShortDateString(), detail.StartTime.Value.ToShortTimeString(), detail.EndTime.Value.ToShortTimeString());
}
e.Cache.SetValue<EPApproval.details>(e.Row, details);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment