Api.Time.GetPeriodNumFromId

This function gets the period number from the current POV Time Id. The period is static and is configured with either months or weeks followed by the period number. For example: M1 – M12 or W1 – W54. It evaluates the period number and then introduces logic to execute the formula.

Api.Time.GetPeriodNumFromId Usage

Example using api.Time.GetPeriodNumFromId :

Copy
'Get Current Period As Integer Based On Current POV TimeId
Dim curPeriod As Integer = api.Time.GetPeriodNumFromId(api.Pov.Time.MemberId)
    BRApi.ErrorLog.LogMessage(si, "Period Number = " & curPeriod)

ErrorLog Result:

Example using api.Time.GetPeriodNumFromId in a working formula:

Copy
'Get Time Member Id to Get Year and Period
Dim timeId As Integer = api.Pov.Time.MemberId

'Get Current Year As Integer Based On Current POV TimeId
Dim curYear As Integer = api.Time.GetYearFromId(api.Pov.Time.MemberId)

'Get Current Period As Integer Based On Current POV TimeId
Dim curPeriod As Integer = api.Time.GetPeriodNumFromId(api.Pov.Time.MemberId)

'Execute Formula only if Current Year is Greater than or Equal to 2018
'AND Current Period Number is Greater than or Equal to 1
If curYear >= 2018 And curPeriod >= 1 Then
    'Only Run for Base Entities and at Local Currency
    If (Not api.Entity.HasChildren() And (api.Cons.IsLocalCurrencyforEntity())) Then
        api.Data.Calculate("A#CashCalc = A#10000")
    End If
End If