01-21-2022
02:43 PM
- last edited on
06-06-2023
08:15 AM
by
JackLacava
Hello,
is there a way to restrict users from force consolidating? Can we control who has access to force consolidate in the system?
Thanks,
Hadi
01-24-2022 06:21 AM
Please check here: https://community.onestreamsoftware.com/t5/Accepted-Code-Samples/Event-Handler-for-Consolidate-with-...
With the si object you get the active user. Then you need to check, if the user is in a group of your choice, using a brapi function, to prevent or allow the force consolidate.
There is a chancel flag to cancel silent, or you can use a brapi function to generated an error with a custom error message. Be careful, an error in the event handler prevents some functions to work.
03-07-2022 03:22 AM
Hi Christian,
I cannot access to your link, it's said "Access Denied. You do not have sufficient privileges for this resource or its parent to perform this action.".
Could you kindly let me know how to access this resource please ?
Thank you very much,
Khanh
04-11-2022 11:14 AM
Hi Khanh, please contact you Onestream services contact or your partner (if you are a customer) to get the information. Regards Christian
08-24-2023 04:43 PM
Hi Khanh
I just implemented something similar. You will need a Business Rule of type Wcf Event Handler
Then the code is something like:
Try
' OneStream provides the lines below
Dim returnValue As Object = args.DefaultReturnValue
args.UseReturnValueFromBusinessRule = False
args.Cancel = False
' before consol starts
If ( args.IsBeforeEvent And (args.WcfServiceType = WcfServiceType.Calculate Or args.OperationName= "StartConsolidation" Or args.OperationName= "StartProcessCube") )
' check if user is in security group OK_CONSOL if he is not then cancel running
If ( Not brapi.Security.Authorization.IsUserInGroup(si,"OK_CONSOL")) Then
args.Cancel = True
' throw in an exception to grab their attention
Throw New XFException(si, New Exception("SOX Violation: User NOT Provisioned to Execute Consolidation."))
End If
End If
Return returnValue
08-31-2023 05:09 PM
Do you create this as a new business rule? and where does it get stored?
09-01-2023 08:27 AM
hello
Yes, as a new business rule. OneStream will automatically save it under Extensibility Rules folder as WcfEventHandler. Do not chance the name or try to move the business rule. The code below is originally provided by OneStream at the time of creation
Imports System
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.Common
Imports System.Globalization
Imports System.IO
Imports System.Linq
Imports System.Windows.Forms
Imports Microsoft.VisualBasic
Imports OneStream.Finance.Database
Imports OneStream.Finance.Engine
Imports OneStream.Shared.Common
Imports OneStream.Shared.Database
Imports OneStream.Shared.Engine
Imports OneStream.Shared.Wcf
Imports OneStream.Stage.Database
Imports OneStream.Stage.Engine
Namespace OneStream.BusinessRule.WcfEventHandler.WcfEventHandler
Public Class MainClass
Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As WcfEventHandlerArgs) As Object
Try
Dim returnValue As Object = args.DefaultReturnValue
args.UseReturnValueFromBusinessRule = False
args.Cancel = False
Dim wfScenarioName As String = ScenarioDimHelper.GetNameFromID(si, si.WorkflowClusterPk.ScenarioKey)
BRApi.ErrorLog.LogMessage(si, $"DMx: {wfScenarioName}")
If (args.WcfServiceType = WcfServiceType.Calculate) Then
If args.OperationName.XFEqualsIgnoreCase("CalculateChartLogic") Then
If args.IsBeforeEvent Then
'Dim insertFailed as Boolean
'ErrorHandler.InsertErrorLogItem(si, XFErrorLevel.Information, "Before " + args.OperationName, XFTier.AppServer, String.Empty, String.Empty, String.Empty, insertFailed)
Else
'Dim insertFailed as Boolean
'ErrorHandler.InsertErrorLogItem(si, XFErrorLevel.Information, "After " + args.OperationName, XFTier.AppServer, String.Empty, String.Empty, String.Empty, insertFailed)
End If
End If
End If
Return returnValue
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Function
End Class
End Namespace