Forum Discussion

Marco's avatar
Marco
Contributor II
2 years ago

How to verify what the Scenario is not locked in BR

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).

  • JackLacava's avatar
    JackLacava
    Honored Contributor

    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.

    • Marco's avatar
      Marco
      Contributor II

      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.

       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's avatar
        JackLacava
        Honored Contributor

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