Pass in parameters to a public function
Morning All,
I'm working on a new solution to avoid having many, many separate confirmation rules with their own code which is almost identical in each case, and instead move to using a public function so that the similar code is recycled. Seems like a sensible idea!
I've got a basic prototype roughly working. So I've created a public function in Finance Business Rules which I am then calling from inside the confirmation rule code.
ie. the first code snippet is the public function and the second code snippet is the confirmation rule code calling it.
So far, so good and I've proved that the public function is indeed running when I run the confirmation rule (the error log message appears as expected) so I'm pleased so far!
What I now want to do is pass in some parameters from each confirmation rule, ie. the only thing that will be different in most cases is which accounts are being checked. So here is where I'm stuck. Within the code that calls the public function I want to be able to put in some variables/account details. I'm thinking I need to use some sort of namevaluepairs code that can be used in the public function but I haven't managed to get this part working.
Does anyone know what the correct syntax is to pass variables from the calling code to the public function? And then how I would access them in the public function?
Thanks in advance!
Richard
Public function that needs to receive some account details from the calling code:
Namespace OneStream.BusinessRule.Finance.UE_Shared_Conf_Rules_A
Public Class MainClass
Public Function SecondFunction(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As FinanceRulesApi, ByVal args As FinanceRulesArgs) As Object
Try
Dim IntegerReturn As Integer = 1234567
Return IntegerReturn
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Function
End Class
End NamespaceCalling code (inside confirmation rule code) that I want to put some account details in to pass to the public function:
Dim SharedRule As New OneStream.BusinessRule.Finance.UE_Shared_Conf_Rules_A.MainClass
brapi.ErrorLog.LogMessage(si,"ShareRule Return is: "& SharedRule.SecondFunction(si,globals,api,args).tostring)
