Forum Discussion

csivark's avatar
csivark
New Contributor
3 years ago

How to update Global Time dynamically via BR

I am trying to write a BR to update the Global Time within the OS application. I see API function to get globaltime (BRApi.Workflow.General.GetGlobalTime). However, I don't see one for setting/updating global time. Is there a API to update the Global Time?

I even searched the tables in the Database to see if I can manually update the record within a table, but didn't come across the table that contains the Global Time. 

Is there a way to update the Global time based on the system time?

Thanks,

 

  • Gaurav's avatar
    Gaurav
    New Contributor III

    Please try using AppProperties:
    BRApi.Utilities.GetApplicationProperties(si).GlobalTime = "2022M10"

    This worked for us. Hope it helps :).
    Best,

    • MCastro's avatar
      MCastro
      New Contributor

      I tried with this example; however, the Global time is only updated during the user session.  The update is only in memory but doesn't update the database.

      Did you have any similar issue?

       

      Thanks,

  • bilbrandon's avatar
    bilbrandon
    New Contributor III

    I added this code to a Data Adapter:

    UPDATE
    AppProperty
    SET
    TextValue = '2022M10'
    WHERE Name = 'GlobalTime'

    After executing the query, the value in the AppProperty table is changed, but the value in the POV pane is not. Log off / log on is needed for the change to take effect.

  • JackLacava's avatar
    JackLacava
    Honored Contributor

    The table containing Global Time and Global Scenario is AppProperty, in the records with Name "GlobalTime" and "GlobalScenario". There is no public Api for it, as far as I can see, so I wouldn't recommend it changing it directly in the database without restarts, but it might work.

  • Gaurav's avatar
    Gaurav
    New Contributor III

    I didn't face any such issue. Have you tried refreshing application?

    FYI, I've been triggering Extender business rule via DM step and scheduled via Task scheduler.

    Best,

     

     

     

  • MCastro's avatar
    MCastro
    New Contributor

    Yes, I refresh the application and the variable is updated correctly. However, after logging out and entering a new user session, it returns to the previous value.

     

    Thanks,

    • Gaurav's avatar
      Gaurav
      New Contributor III

      Hey,

      I tested it again in lower environment and you were right it doesn't update correctly.

      I checked with OneStream support and BRApi.Utilities.GetApplicationProperties(si).GlobalTime will only hold  cached values. It won't update it at the DB level.

      Now, I'm also moving to SQL solution suggested by bilbrandon.

      Thanks,

      Gaurav

      • Bansal_P's avatar
        Bansal_P
        New Contributor II

        Hi Gaurav,

        Even after using the SQL query, the same was not reflected in the UI. Do you know how we can achieve that?
        Thanks,
        Pragyanshu

  • RKK's avatar
    RKK
    New Contributor

    I have used below SQL code to update the Global time but is not updating and also written BR but that is also not working out can one pls help me on this.

    SELECT DISTINCT


    CASE WHEN Textvalue='2023M5' then '2023M6'


    End as Textvalue


    From AppProperty