Forum Discussion
2 Replies
Sort By
- chulContributor III
You could probably do that by turning on the submit/approve process on the WF, use the event handler (FinalizeSubmitJournal) to check the journal name and send an email to either the approver if it passes or the creator if it fails. However, it wouldn't prevent the approval of a journal with a bad name as long as it meets the journal template data requirements (e.g. balanced).
- MarcusHValued Contributor
The GolfStream application has examples of the FinalizeSubmitjournal event plus sending an email as chul recommends. The CPM BluePrint marketplace application also uses a JournalsEventHandler and that displays messages if certain criteria are not met. Here is the CPM BluePrint event handler:
Imports System Imports System.Data Imports System.Data.Common Imports System.IO Imports System.Collections.Generic Imports System.Globalization Imports System.Linq Imports Microsoft.VisualBasic Imports System.Windows.Forms Imports OneStream.Shared.Common Imports OneStream.Shared.Wcf Imports OneStream.Shared.Engine Imports OneStream.Shared.Database Imports OneStream.Stage.Engine Imports OneStream.Stage.Database Imports OneStream.Finance.Engine Imports OneStream.Finance.Database Namespace OneStream.BusinessRule.JournalsEventHandler.JournalsEventHandler Public Class MainClass '------------------------------------------------------------------------------------------------------------ 'Reference Code: JournalEventHandler ' 'Description: Event handler to ensure process/approve/post are done by different users to enable ' seggregation of duties ' 'Usage: Executes when a Journal action is run and fires this business rule. ' 'Created By: OneStream Software '------------------------------------------------------------------------------------------------------------ Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As JournalsEventHandlerArgs) As Object Try 'on/off switch to control logic from running Dim processEvents As Boolean = False Dim returnValue As Object = args.DefaultReturnValue args.UseReturnValueFromBusinessRule = False args.Cancel = False 'Evaluate the operation type in order to determine which subroutine to process Select Case args.OperationName Case Is = BREventOperationType.Journals.ApproveJournal If processEvents Then 'APPROVED - Check approver against submitter OSB_HandleApproveJournal(si, globals, api, args) End If Case Is = BREventOperationType.Journals.PostJournal If processEvents Then 'POST - Check poster against submitter & approver OSB_HandlePostJournal(si, globals, api, args) End If End Select Return returnValue Catch ex As Exception Throw ErrorHandler.LogWrite(si, New XFException(si, ex)) End Try End Function #Region "Finalize Approve Helpers" Private Sub OSB_HandleApproveJournal(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As JournalsEventHandlerArgs) '------------------------------------------------------------------------------------------------------------ 'Reference Code: XFR_HandleFinalizeApproveJournal ' 'Description: Display a message to the user to not allow journal approval if they were the submitter. ' 'Usage: Used to alert the journal approver that they cannot approve a journal if they were the submitter. ' 'Created By: OneStream Software '------------------------------------------------------------------------------------------------------------ Try 'APPROVED - Check approver against submitter If (args.IsBeforeEvent = False) Then Dim journalID As JournalEx = DirectCast(args.Inputs(1), JournalEx) If Not journalID Is Nothing Then 'Make sure that the journal is being approved by someone other than the submitter before we send an email If (JournalID.Header.Header.SubmittedUserID = si.AuthToken.UserUniqueID) Then Throw New XFException(si, New Exception("Error: You cannot quick post or approve a journal you submitted.")) End If End If End If Catch ex As Exception Throw ErrorHandler.LogWrite(si, New XFException(si, ex)) End Try End Sub #End Region #Region "Finalize Post Helpers" Private Sub OSB_HandlePostJournal(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As JournalsEventHandlerArgs) '------------------------------------------------------------------------------------------------------------ 'Reference Code: XFR_HandleFinalizePostJournal ' 'Description: Display a message to the user to not allow journal posting if they were the submitter and/or approver. ' 'Usage: Used to alert the journal poster that they cannot post a journal if they were the submitter/approver. ' 'Created By: OneStream Software '------------------------------------------------------------------------------------------------------------ Try 'APPROVED - Check poster against submitter/approver If (args.IsBeforeEvent = False) Then Dim journalID As JournalEx = DirectCast(args.Inputs(1), JournalEx) If Not journalID Is Nothing Then 'Make sure that the journal is being posted by someone other than the submitter before we send an email If ((JournalID.Header.Header.ApprovedUserID = si.AuthToken.UserUniqueID)) Then Throw New XFException(si, New Exception("Error: You cannot post a journal you submitted or approved.")) End If End If End If Catch ex As Exception Throw ErrorHandler.LogWrite(si, New XFException(si, ex)) End Try End Sub #End Region End Class End Namespace
Related Content
- 3 years ago
- 3 years ago
- 2 years ago
- 12 months ago