Individueller Objekt-Aufruf (Lohnabrechnung etc.) |
Task #6937 und #10748 | 5058.000
1.)How do Events work? 1.)Starting from which version are Events available? 2.)Use cases published by SwissSalary For this purpose, partners can program a subscriber event that waits for a released Publisher event and then deals with it. A subscriber enables partners to hook into the core functionality of the application without having to make traditional code changes. -Adjusted payslip use case Save the adjusted payslip as a PDF Send the adjusted to Direct -Adjusted wage statement use case Save the adjusted wage statement as a PDF Send the adjusted wage statement to Direct 3.)Sample codes for Subscriber events [EventSubscriber(ObjectType::Codeunit, Codeunit::"SwS Bulk Report Management", 'OnBeforeSavePaycheckAsPdf', '', false, false)] local procedure HandleOnBeforeSavePaycheckAsPdf(pPayrollHead: Record "SwS Payroll Head"; pReportID: Integer; pReportParams: Record "SwS Working Table"; var pDescription: Text[1024]; var pHandled: Boolean; var pPaycheckTempBlob: Record "SwS TempBlob") begin SaveCustomPaycheckAsPdf(pPayrollHead, pReportParams, pPaycheckTempBlob, pDescription); pHandled := true; end; local procedure SaveCustomPaycheckAsPdf(pPayrollHead: Record "SwS Payroll Head"; pReportParams: Record "SwS Working Table" temporary; var pPaycheckTempBlob: Record "SwS TempBlob"; var pDescription: Text[1024]) var CustomReport: Report "SwS Custom Paycheck"; Employee: Record "SwS Employee"; PayrollHeadWithNoFilters: Record "SwS Payroll Head"; FileTempBlobOutStream: OutStream; begin // Template for custom paycheck report if (pPayrollHead."Payroll No." = 0) or (pPayrollHead."Employee No." = '') then Error('No pay process found. Error code %1', 1005);
Clear(CustomReport); CustomReport.SetTableView(PayrollHeadWithNoFilters); // Set all user specific filters on DataItem back to empty CustomReport.UseRequestPage(false); CustomReport.SetReportParams(pReportParams); CustomReport.SetSinglePaycheckFilter(pPayrollHead."Payroll No.", pPayrollHead."Employee No.");
Clear(FileTempBlobOutStream); pPaycheckTempBlob.Blob.CreateOutStream(FileTempBlobOutStream); CustomReport.SaveAs('', REPORTFORMAT::Pdf, FileTempBlobOutStream); Employee.Get(pPayrollHead."Employee No."); pDescription := 'Lohnabrechnung Custom'; end; 4.)Other sample codes for Subscriber events There is also theoretical possibility to adjust the email subject or text (body): local procedure HandleOnCreateMessageAuto(var pToRecipients: List of [Text]; var pSubject: Text; var pBody: Text; var pHandled: Boolean) begin pToRecipients.RemoveRange(1, pToRecipients.Count());
pToRecipients.Add('max.muster@gmail.com'); pToRecipients.Add('aziz.mulaj@swisssalary.ch'); end;
Since the same function is also used by the “Payslip PDF” report, the code would have to be adjusted a little if the recipients are not to be changed when emailing the payslip.
5.)Microsoft event publishers used to replace report calls local procedure HandleOnAfterSubstitueReport(ReportId: Integer; var NewReportId: Integer) begin IF ReportId = REPORT::"SwS Paycheck" THEN NewReportId := REPORT::"SwS Custom Paycheck"; end; |