What is the globals object good for?
Hi all
What is the globals object good for we are seeing in all the business rules?

Hi all
What is the globals object good for we are seeing in all the business rules?

With the globals variable, you can store data or objects globally and transfer it from one process steps to another.
This is a sample how to count process steps
Dim aSimpleCounter As Integer
'lock the process to avoid overrides
SyncLock Globals.LockObjectForInitialization
'Initialize aSimpleCounter with the stored variable, or initialize it with 0
simpleCounter = globals.GetInt32Value("SimpleCounter", 0)
'Count it up by 1
simpleCounter +=1
'Save it to globals
globals.SetInt32Value("SimpleCounter", simpleCounter)
End SyncLockYou can also store objects like list or dictionaries in globals
Dim nameToStore As String = "MyObjectName"
'Definition of a list
Dim anyObject As list(of string)
'lock the process to avoid multiple initialisations
SyncLock Globals.LockObjectForInitialization
'Check if the object is already stored in globals
anyObject = globals.GetObject(nameToStore)
'If not initialize it
If anyObject Is Nothing Then
'create and populate the list
anyObject = New list(of string)
anyObject.add("One")
anyObject.add("Stream")
anyObject.add("Software")
globals.SetObject(nameToStore , anyObject)
End If
End SyncLock
'Continue workingBe careful, many object like list and dictionaries are not supporting mutithreaded (support working in parallel), so you can not use them to add members to the list during a report or a consolidation.
But there are multithreaded versions you can use for this purpose
'Additional Imports for concurent list and dictionary
Imports System.Collections.Concurrent
'create a concurrent dictionary
Dim concDict As New ConcurrentDictionary()Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.