跳至主要內容
Adaptive Planning
ai.calendar

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 ] )
  • period: String Value of the period to get next period of time for
  • options: Object Object containing a type property 'number' and a value property as an int. Example: {type: 'number', value: 3}
ai.calendar.period
Returns the next Period in the
Adaptive Planning
Calendar from the period passed in the argument
getPreviousPeriod( period [, options ] )
  • period: String Value of the period to get previous period of time for
  • options: Object Object containing a type property 'number' and a value property as an int. Example: {type: 'number', value: 3}
ai.calendar.period
Returns the previous Period in the
Adaptive Planning
Calendar from the period passed in the argument
getAvailablePeriodTypes( periodType )
  • periodType: String Stratum code of one of the available Strata.
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 )
  • period: ai.calendar.period Period you want to get the start date time for
String
Returns the start date time for the period in ISO8601 date string format (ex '2015-06-15T12:00:00+10:00')
getPeriodEndDateTime( period )
  • period: ai.calendar.period Period you want to get the end date time for
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 )
  • start: String ISO8601 formatted start date of the period to convert
  • end: String ISO8601 formatted end date of the period to convert
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 )
  • start: String ISO8601 formatted start date of the period to convert
  • end: String ISO8601 formatted end date of the period to convert
  • periodFrom: ai.calendar.period Period from which you want to compare
  • periodEnd: ai.calendar.period Period to which you want to compare
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
Method
Parameters
Returns
Description
getValue()
string
Returns 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()); }