05-11-2023 10:41 AM - edited 05-11-2023 10:42 AM
Within the Extender business rule used to integrate with our ERP system I would like to loop through all the "Import" steps within a specific node of workflow hierarchy and to read the values of the "TextX" properties. I've heard that this is possible but have no idea where to start. Any guidance would be greatly appreciated.
Yan
Solved! Go to Solution.
05-11-2023 02:25 PM - last edited on 04-23-2024 04:35 AM by JackLacava
Yup! Makes total sense what you are striving for. The generalized strategy would be:
If we just focus on the first two components it might look something like the below. For clarity I'll assume the following structure:
Parent Level Workflow Group
|--- Workflow1
|----- Import
|----- Forms
|----- Adj
|--- Workflow2
|----- Import
|----- Forms
|----- Adj
|--- Etc...
Getting the list of .Import workflows (Workflow1.Import, Workflow2.Import):
Dim parentWfProfileInfo As WorkflowProfileInfo = BRApi.Workflow.Metadata.GetProfile(si, _
"Parent Level Workflow Group")
Dim baseWfProfileInfo As New List (Of WorkflowProfileInfo)( _
BRApi.Workflow.Metadata.GetRelatives(si, _
BRApi.Workflow.General.GetWorkflowUnitClusterPk(si, _
parentWfProfileInfo.Name, "YourScenarioName", "YourApplicableTimePeriod"), _
WorkflowProfileRelativeTypes.Descendants, _
WorkflowProfileTypes.InputImportChild ))
Getting the TextX Attributes for each base .Import profile:
Dim textXAttribute As New List(Of String) 'will store the value of attribute from each profile
For Each profile In baseWfProfileInfo
textXAttribute.Add( _
profile.GetAttribute( _
scenarioType.TheAssociatedScenarioType.Id, _
sharedconstants.WorkflowProfileAttributeIndexes.Text1 _
).Value ) 'I assume Text1 here
Next
At this point the textXAttribute is a list of strings containing the pieces you were after. You can do your SFTP comparison logic against this. Or turn this into a delimited string, etc. etc.
One thing to note! I'm assuming the textX attributes are stored at the .Import level. If they are stored one level up you'll change the GetRelatives section.
Whew! Hope that makes sense or is enough to get you started in the correct direction. Follow-ups are welcomed.
Cheers! -db
05-11-2023 01:01 PM
Hi YanSavinsky: what's the end goal? As is typical with OneStream there are often times multiple ways to achieve an outcome. We might be able to recommend strategies with a clearer picture of the objective.
To answer your question as listed: you'll be working with BRApi.Workflow.Metadata functions.
Example: Getting your profile: BRApi.Workflow.Metadata.GetProfile(...)
Example: with your profile object, getting attributes: wfProfileInfo.GetAttribute(...)
Some reference material: Solved: Workflow Profile's Substitution Text Settings in BRAPI rule - OneStream Community (onestream... | Solved: BRAPI rule for getting Text field from Workflow - OneStream Community (onestreamsoftware.com...
05-11-2023 01:32 PM
Thank you for your reply, db_pdx.
Currently I have a set of extender BRs that all do the same thing: connect to the SFTP server, look for a text file with a specific name and if the file is present pick it up, move it to OS Harvest folder and load it using a specific workflow profile. The rules are identical except for the name of the file the rule looks for and the workflow profile being used. The rules are engaged via steps in a DM sequence that runs on schedule. That means that several connection sessions to the SFTP server are created in quick secession. I would like to consolidate this process into a single BR running via a single step that will create a single connection session.
I hope this provides enough of a context but please let me know if more is needed.
Thanks again.
Yan.
05-11-2023 02:25 PM - edited 05-11-2023 02:26 PM
Q1. I would like to loop through all the "Import" steps within a specific node of workflow hierarchy
Answer
'Declare scenario and gtime.
Dim parentWorkFlow as string = "parentWorkFlow Name"
For Each pwf As String In parentWorkFlow
Dim wfClusterPk2 As WorkflowUnitClusterPk = BRApi.Workflow.General.GetWorkflowUnitClusterPk(si, pwf, scenario, gTime)
Dim objList As List(Of WorkFlowProfileInfo) = BRApi.Workflow.Metadata.GetRelatives(si, wfClusterPk2, WorkflowProfileRelativeTypes.Descendants, WorkflowProfileTypes.InputImportChild)
finalWFList.AddRange(objList)
Next
Q2. To read the values of the "TextX" properties.
Answer
For Each w As WorkflowProfileInfo In finalWFList
If w.GetAttributeValue(ScenarioTypeID.Administration, textFieldUsed).StartsWith("Textfield Value") Then
' Do all your load stuff
End If
Next
05-11-2023 02:31 PM
Ninja! 😛 lol. But also your formatting is better!
05-11-2023 04:09 PM
Thank you very much, OS_Pizza.
I'll second DB's praise!
05-11-2023 02:25 PM - last edited on 04-23-2024 04:35 AM by JackLacava
Yup! Makes total sense what you are striving for. The generalized strategy would be:
If we just focus on the first two components it might look something like the below. For clarity I'll assume the following structure:
Parent Level Workflow Group
|--- Workflow1
|----- Import
|----- Forms
|----- Adj
|--- Workflow2
|----- Import
|----- Forms
|----- Adj
|--- Etc...
Getting the list of .Import workflows (Workflow1.Import, Workflow2.Import):
Dim parentWfProfileInfo As WorkflowProfileInfo = BRApi.Workflow.Metadata.GetProfile(si, _
"Parent Level Workflow Group")
Dim baseWfProfileInfo As New List (Of WorkflowProfileInfo)( _
BRApi.Workflow.Metadata.GetRelatives(si, _
BRApi.Workflow.General.GetWorkflowUnitClusterPk(si, _
parentWfProfileInfo.Name, "YourScenarioName", "YourApplicableTimePeriod"), _
WorkflowProfileRelativeTypes.Descendants, _
WorkflowProfileTypes.InputImportChild ))
Getting the TextX Attributes for each base .Import profile:
Dim textXAttribute As New List(Of String) 'will store the value of attribute from each profile
For Each profile In baseWfProfileInfo
textXAttribute.Add( _
profile.GetAttribute( _
scenarioType.TheAssociatedScenarioType.Id, _
sharedconstants.WorkflowProfileAttributeIndexes.Text1 _
).Value ) 'I assume Text1 here
Next
At this point the textXAttribute is a list of strings containing the pieces you were after. You can do your SFTP comparison logic against this. Or turn this into a delimited string, etc. etc.
One thing to note! I'm assuming the textX attributes are stored at the .Import level. If they are stored one level up you'll change the GetRelatives section.
Whew! Hope that makes sense or is enough to get you started in the correct direction. Follow-ups are welcomed.
Cheers! -db
05-11-2023 04:01 PM
Thank you very much, DB.
That is VERY helpful!