Use getPlanningAreaInfo API to Define Planning Area

As an application designer or story developer, you can use getPlanningAreaInfo with filter related APIs to define the planning area. You can further use startEditMode and copy API to edit or copy the customized planning area.

You can use getPlanningAreaInfo API, which returns the PlanningAreaInfo object, which is intialized with filters applied to the table. If the data source associated with the table doesn't support planning, undefined is returned.
Code Syntax
getPlanningAreaInfo(): PlanningAreaInfo | undefined
You can use the following APIs with the PlanningAreaInfo object to define the planning area that isn't in the table context:
  • removeFilter: Remove any filter that is set on the dimension.
    Code Syntax
    removeFilter(dimension: string | DimensionInfo): PlanningAreaInfo
  • changeFilter: Sets a filter on the dimension. Any existing filter on the dimension is overwritten.
    Code Syntax
    changeFilter(dimension: string | DimensionInfo, memberInfo: PlanningAreaMemberInfo): PlanningAreaInfo

    The PlanningAreaMemberInfo object can be passed as a JSON object to method arguments. It has members and hierarchy as properties.

  • getFilters: Returns filters that define the planning area. Filters on Version and Measure dimensions are ignored.
    Code Syntax
    getFilters(): PlanningAreaFilter[]

    The PlanningAreaFilter has dimension, members, hierarchy and property as properties.

Here's a script example that defines the planning area with filters applied to Table_1:
Sample Code
var planningAreaInfo = Table_1.getPlanning().getPlanningAreaInfo(); // Returns a PlanningAreaInfo object, which is initialized with the filters applied to Table_1

if (planningAreaInfo){
  planningAreaInfo.removeFilter("Date"); // ignore filters on "Date" dimension
  planningAreaInfo.changeFilter("Generic", { "hierarchy": "H1", "members": ["[Generic].[H1].&[A]"] }); // Overwrites or adds "Generic" dimension filter

  var planningAreafilters = planningAreaInfo.getFilters();
  console.log(planningAreafilters); // Prints out filters
  /* Examples of the filters
    [{
        "dimension": "Generic",
        "hierarchy": "H1",
        "members": [
            "A"
        ],
        "property": "ID"
    }]
  */
}