How to verify what the Scenario is not locked in BR

Marco
Contributor

Hi Everyone!.
I have the problem that a button is applying processes to a closed Forecast, for example, the open forecast is for June, but a user could select March or April and reapply those processes to those months that are supposed to be locked. In my case, it applies those processes even when the selected Forecast is closed, so it would help me if you could show me a way to validate it in the BR so that that process does not run (By process, I also refer to Data Management or a Business Rule).

5 REPLIES 5

JackLacava
Community Manager
Community Manager

Locking is a Workflow operation, so you'll have to reason in terms of Workflow - or better, in terms of Workflow Data Unit (also known as Level 2 Data Unit), which is the unique combination of a Workflow, a Scenario member, and a Time member.

' First, define the Primary Key of the Workflow DU you're interested in
' In this example we use what the user has currently selected.
Dim wfCPk As New WorkflowUnitClusterPk( _
   si.WorkflowClusterPk.ProfileKey, _
   si.WorkflowClusterPk.ScenarioKey, _
   si.WorkflowClusterPk.TimeKey)

' Then retrieve the current status 
Dim wfInfo As WorkflowInfo = BRApi.Workflow.Status.GetWorkflowStatus(si, wfCPk, True)

if wfInfo.Locked then
  ...
end if

If you actually Close workflows (which is not recommended) rather than just locking them, you'll have to check that with GetWorkflowState instead.

Hi JackLacava, 
I'm grateful that you respond to all the questions I've posted. In this case, I wanted to see a way to know if the scenario is locked because I have a dashboard that has that parameter and the entity one, but it is in a separate workflow profile. So your solution works for me when I'm in the indicated workflow profile, but not when I'm in an admin one, for example.1.png

 As shown in the image, I'm in an admin work profile, and even though the scenario is locked, when I move to other WFProfiles, it's not locked here.

 

JackLacava
Community Manager
Community Manager

Just create the WorkflowUnitClusterPk objects passing other parameters, i.e. another profile key, scenario, or time.

I'm new to this functions, but is there a way to obtain the WFprofile through the entity? I only have the entity values and the scenario to verify if the scenario is locked or not. Alternatively, is it possible to view it through an SQL table?

JackLacava
Community Manager
Community Manager

Search in the api helper tree that you get on the left of the editor, there are functions and snippets to retrieve a specific Workflow Profile by name.

For the record, an Entity can be assigned to multiple profiles for different scenarios, so you'll have a hard time going that way. Some people do it by typing the profile name in one of the Text properties of the entity, but then you have to remember to keep things in sync. It makes more sense to reason in terms of Workflow first.