Forum Discussion

ssmith-nova's avatar
ssmith-nova
New Contributor III
7 months ago

WorkflowUnitClusterPk vs WorkflowUnitPk

What is the difference between WorkflowUnitClusterPk vs WorkflowUnitPk? When would you use one over the other?   Thanks, Scott
  • franciscoamores's avatar
    7 months ago

    In the Workflow Unit Cluster Pk object you can access:

    • Profile Key 
    • Scenario Key
    • Time Key

    The Workflow Unit Pk is the Workflow Unit Cluster Pk + the Workflow Key.

    The workflow key identifies the "Workflow Name" so what you se here:

    All Workflow keys available are in SharedConstants.WorkflowKeys. For example, "Import, Validate and Load" is the Workflow SharedConstants.SimpleDataLoad.

    I use any of the two depending on what the method that I want call gets as input parameter. Most of them are usually getting the WFU Cluster PK as that identifies your selection in open place. Indeed, you can create the WF Unit Cluster PK from the WF Unit PK using method CreateWorkflowUnitClusterPk().

    HTH.

  • RobbSalzmann's avatar
    7 months ago

    WorkflowUnitPk can be used as a factory object with error checking to create instances of WorkflowUnitClusterPK:

    Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As ExtenderArgs) As Object
    	Try
    		Dim profileKey As Guid = New Guid(args.NameValuePairs.XFGetValue("ProfileKey"))
    		Dim scenarioId As Integer = ConvertHelper.ToInt32(args.NameValuePairs.XFGetValue("ScenarioId"))
    		Dim timeId As Integer = ConvertHelper.ToInt32(args.NameValuePairs.XFGetValue("TimeId"))
    		Dim wfClusterPK As WorkflowUnitClusterPk
    		Dim wfUnitPK As New WorkflowUnitPk(profileKey, scenarioId, timeId)
    		
    		If wfUnitPK.KeyInitialized Then
    			wfClusterPK = wfUnitPK.CreateWorkflowUnitClusterPk()
    		Else
    			BRApi.ErrorLog.LogError(si, XFErrorLevel.Error, "Workflow could not be intialized")
    		End If
    
    		Return Nothing
    	Catch ex As Exception
    		Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
    	End Try
    End Function