ai.calendar
A period of time that can contain raw or aggregated data. See Steps: Change Calendars.
Functions
Method
| Parameters
| Returns
| Description
|
|---|---|---|---|
getNextPeriod( period [, options ] ) |
| ai.calendar.period | Returns the next Period in the Adaptive Planning Calendar from the period passed in the argument |
getPreviousPeriod( period [, options ] ) |
| ai.calendar.period | Returns the previous Period in the Adaptive Planning Calendar from the period passed in the argument |
getAvailablePeriodTypes( periodType ) |
| Array<String> | Returns array of Stratum (Period type) codes supported by the calendar higher in the hierarchy than the stratum passed in (ex ['QuarterYear', 'HalfYear', 'Year'] ) |
getPeriodStartDateTime( period ) |
| String | Returns the start date time for the period in ISO8601 date string format (ex '2015-06-15T12:00:00+10:00') |
getPeriodEndDateTime( period ) |
| String | Returns the end date time for the period in ISO8601 date string format (ex '2015-06-15T12:00:00+10:00') |
convertToAdaptivePeriodStart ( start, end ) |
| String | Returns the corresponding Adaptive Planning Period start date in ISO8601 date string format (ex '2015-06-15T12:00:00+10:00') |
isWithinAdaptivePeriodRange ( start, end, periodFrom, periodEnd ) |
| Boolean | Returns true if both the start date and end date given falls within the 2 the from period and to period. Returns false otherwise. (ex true/false) |
Examples
Example for getNextPeriod( period [, options ] ) and getPeviousPeriod( period [, options ] )
function PreviewData(context) { var calendar = context.getCalendar(); var dataSource = context.getDataSource(); var periods = dataSource.getSetting("Periods").getValue(); // getNextPeriod var nextMonth = calendar.getNextPeriod(periods.getFromPeriod()); //getPreviousPeriod var prevMonth = calendar.getPreviousPeriod(periods.getFromPeriod()); }
Example for convertToAdaptivePeriodStart ( start, end )
function PreviewData(context) { var calendar = context.getCalendar(); var newDate = calendar.convertToAdaptivePeriodStart(ai.date.create('2016-02-01', 'America/Los_Angeles'), ai.date.create('2016-05-01', 'America/Los_Angeles')); // write the corresponding Adaptive Planning period start date to log. ai.log.logInfo(newDate); //Assuming server is in PST timezone, the corresponding output is '2016-04-01T00:00:00.0000000-07:00' }
Example for getAvailablePeriodTypes( periodType )
function PreviewData(context) { var dataSource = context.getDataSource(); var calendar = context.getCalendar(); var availableTypeMonth = calendar.getAvailablePeriodTypes('month'); var availableTypeQuarter = calendar.getAvailablePeriodTypes('qtr'); var availableTypeYear = calendar.getAvailablePeriodTypes('year'); ai.log.logInfo("Stratum code of one of the available Strata for month: "+availableTypeMonth); ai.log.logInfo("Stratum code of one of the available Strata for quarter: "+availableTypeQuarter); ai.log.logInfo("Stratum code of one of the available Strata for year: "+availableTypeYear); } //Stratum code of one of the available Strata for month: month,qtr,year //Stratum code of one of the available Strata for quarter: qtr,year //Stratum code of one of the available Strata for year: year
ai.calendar.period
A time period that can contain raw or aggregated data.
- Functions
- MethodParametersReturnsDescriptiongetValue()stringReturns the string value of the Period that child columns that can be used to pass to Calendar functions as arguments.
- Example
- function PreviewData(context) { var dataSource = context.getDataSource(); var calendar = context.getCalendar(); var periods = dataSource.getSetting("Periods").getValue(); var period = calendar.nextPeriod(periods.getFromPeriod()); var nextPeriod = calendar.nextPeriod(period.getValue()); }