Forum Discussion
Hi there,
Guessing you probably solved this one already, but if you create a JournalsEventHandler business rule with the following, it will prevent a journal from being posted without an attachment.
Public Class MainClass
Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As JournalsEventHandlerArgs) As Object
Select Case args.OperationName
Case Is = BREventOperationType.Journals.PostJournal
'Attachment Check:
Dim wfClusterPk As WorkflowUnitClusterPk = si.WorkflowClusterPk
Dim Info1 As String = Nothing
Dim objList As JournalsAndTemplatesForWorkflow = BRApi.Journals.Metadata.GetJournalsAndTemplates(si,wfClusterPK,)
'Define counter
Dim x As Integer = 0
'Set cycle
For x = 0 To objList.Journals.Count - 1
'Get line items in current journals
Dim objJournalEx As JournalEx = BRApi.Journals.Metadata.GetJournalOrTemplate(si, objList.Journals.Item(x).Name)
'Check for attachment
If objJournalEx.Header.HasAttachments = False Then
Throw New Exception("Error: Journals must have supporting documents attached before posting")
Else
Return Nothing
End If
Next
End Select
End Function
End Class
Related Content
- 4 years ago
- 3 years ago