08-19-2022 12:19 PM - last edited on 05-03-2023 09:32 AM by JackLacava
Hello
I have built a workflow structure for a statutory application where every legal entity has is own workflow.
In the entity assignment only 1 entity is assigned to the specific workflow.
Data load and input forms work fine because Onestream blocks user to enter data on an entity <> from the WF entity.
Inside each entity workflow we enabled the user to post adjustments.
But for journals Onestream behaves differently. Because when creating a journal, Onestream propose the list of companies the user has access to regardless which is the company assigned to the workflow.
Here I am in the workflow of company 1.
But Onestream prompt with the list of entities I have access to. So I can post a journal on entity XYZ on "company 1 workflow". So I am allowed to post a journal on an entity outside the assigned workflow.
Is there a way to force the user to post a journal only to the workflow entity?
Thanks,
Marcello
Solved! Go to Solution.
08-23-2022 08:28 AM
Hi Marcello - you can create a JournalsEventHandler under Extensibility Rules. Then you can insert this code to restrict submitting journals to Entities assigned to the WF:
Select Case args.OperationName
Case Is = BREventOperationType.Journals.SubmitJournal
'SUBMIT - only allow submitting to WF Entities
Me.XFR_HandlePosttoWFEntities(si, globals, api, args)
Private Sub XFR_HandlePosttoWFEntities(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As JournalsEventHandlerArgs)
'------------------------------------------------------------------------------------------------------------
'Reference Code: XFR_HandlePosttoWFEntities
'
'Description: Display a message to the user to not allow journal posting to Entities outside of the WF
'
'Usage: Used to alert the journal submitter that they cannot submit to Entities outside of their WF
'
'Created By: OS
'------------------------------------------------------------------------------------------------------------
Try
If (args.IsBeforeEvent = True) Then
Dim jEx As JournalEx = DirectCast(args.inputs(1), JournalEx)
Dim ExceptionMessage As String = String.Empty
Dim FailedEntities As New list(Of String)
Dim lEI As New list(Of Integer)
For Each ei As WorkflowProfileEntityInfo In BRApi.Workflow.Metadata.GetProfileEntities(si, jEx.Header.Header.WorkflowProfileID)
lEI.Add(ei.EntityMemberID)
Next
If lEI.Count > 0 Then
For Each li As JournalLineItemEx In jEx.LineItems
If Not lEI.Contains(li.LineItem.EntityId) Then
Dim FailedEntity As Member = BRApi.Finance.Members.GetMember(si, DimType.Entity.Id, li.LineItem.EntityId)
If Not FailedEntities.Contains(FailedEntity.Name) Then
FailedEntities.add(FailedEntity.Name)
End If
End If 'If Not lEI.Contains(li.LineItem.EntityId)
Next
If FailedEntities.Count > 0 Then
If FailedEntities.Count = 1 Then
ExceptionMessage = "Entity ""E#" & String.Join(",E#",FailedEntities) & """ is not assigned to the current workflow. Please modify the journal to only include valid entities and reload." & vbCrLf
Else
ExceptionMessage = "Entities ""E#" & String.Join(",E#",FailedEntities) & """ are not assigned to the current workflow. Please modify the journal to only include valid entities and reload." & vbCrLf
End If
End If 'If FailedEntities.Count > 0
End If 'If lEI.Count > 0
End If 'If (args.IsBeforeEvent = True)
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Sub
08-23-2022 08:28 AM
Hi Marcello - you can create a JournalsEventHandler under Extensibility Rules. Then you can insert this code to restrict submitting journals to Entities assigned to the WF:
Select Case args.OperationName
Case Is = BREventOperationType.Journals.SubmitJournal
'SUBMIT - only allow submitting to WF Entities
Me.XFR_HandlePosttoWFEntities(si, globals, api, args)
Private Sub XFR_HandlePosttoWFEntities(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As JournalsEventHandlerArgs)
'------------------------------------------------------------------------------------------------------------
'Reference Code: XFR_HandlePosttoWFEntities
'
'Description: Display a message to the user to not allow journal posting to Entities outside of the WF
'
'Usage: Used to alert the journal submitter that they cannot submit to Entities outside of their WF
'
'Created By: OS
'------------------------------------------------------------------------------------------------------------
Try
If (args.IsBeforeEvent = True) Then
Dim jEx As JournalEx = DirectCast(args.inputs(1), JournalEx)
Dim ExceptionMessage As String = String.Empty
Dim FailedEntities As New list(Of String)
Dim lEI As New list(Of Integer)
For Each ei As WorkflowProfileEntityInfo In BRApi.Workflow.Metadata.GetProfileEntities(si, jEx.Header.Header.WorkflowProfileID)
lEI.Add(ei.EntityMemberID)
Next
If lEI.Count > 0 Then
For Each li As JournalLineItemEx In jEx.LineItems
If Not lEI.Contains(li.LineItem.EntityId) Then
Dim FailedEntity As Member = BRApi.Finance.Members.GetMember(si, DimType.Entity.Id, li.LineItem.EntityId)
If Not FailedEntities.Contains(FailedEntity.Name) Then
FailedEntities.add(FailedEntity.Name)
End If
End If 'If Not lEI.Contains(li.LineItem.EntityId)
Next
If FailedEntities.Count > 0 Then
If FailedEntities.Count = 1 Then
ExceptionMessage = "Entity ""E#" & String.Join(",E#",FailedEntities) & """ is not assigned to the current workflow. Please modify the journal to only include valid entities and reload." & vbCrLf
Else
ExceptionMessage = "Entities ""E#" & String.Join(",E#",FailedEntities) & """ are not assigned to the current workflow. Please modify the journal to only include valid entities and reload." & vbCrLf
End If
End If 'If FailedEntities.Count > 0
End If 'If lEI.Count > 0
End If 'If (args.IsBeforeEvent = True)
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Sub
09-07-2022 05:09 AM
Hi Eric,
thanks for sharing the rule. It's working fine.
I only needed to add just 1 line more after
ExceptionMessage = "Entities ""E#" & String.Join(",E#",FailedEntities) & """ are not assigned to the current workflow. Please modify the journal to only include valid entities and reload." & vbCrLf
The line is this
Throw New XFUserMsgException (si, Nothing , Nothing, ExceptionMessage)
that popups the error message and block the user from posting the journal.
Marcello
08-29-2022 04:43 PM
Hi Marcello,
It's not a resolution but there's a bug request out there for OS to fix so please feel free to submit a ticket to OS support and add yourself to:
PF-3011: "Journal entry posting via XFJ Import (Excel/CSV) is not restricted to entities attached to the workflow profile via an Entity Filter"
I just found this same issue last week so it's serendipitous timing!
Thanks,
Nicole
09-07-2022 05:10 AM
Hi Nicole
I added myself to the same bug request.
Thanks,
Marcello