The Calendar in SAP Analytics Cloud (SAC) is a powerful framework for orchestrating planning processes, tasks, and workflows across teams. Each calendar event or process carries context filters — such as Date, Version, or Proficenter etc. — that define the specific slice of data being worked on by a team or user.
In some cases, administrators or power users may need to update these context filters in bulk, for example when moving from one fiscal year to another.
While this can be done manually using the Calendar List workspace (where multiple events can be selected and edited together), alternatively scripting provides a faster, automated way to achieve the same — especially when you need to apply changes dynamically.
This approach is inspired by the SAP Community blog written by @mike688
Experience Sharing – How to Batch Modify the Assignees of Calendar Events Using Scripting in SAC, which demonstrates how to modify event assignees in bulk using the Calendar Integration API.
In this post, we extend the same idea — but instead of assignees, we modify dimension context filters for multiple events at once.
You can update context filters directly using the Calendar List workspace:
Steps:
Navigate to Calendar → List workspace.
Select multiple events that you want to modify.
Click Edit Events.
Choose Context, and update filters such as Date, Version, or Category.
This method works well for manual batch updates, especially when the changes are straightforward and performed occasionally.For detailed reference, see SAP’s documentation: Editing Multiple Calendar Events at Once
The Calendar Integration API in SAC allows developers to access and modify multiple calendar tasks and processes programmatically.
You can learn more about this API and its supported operations in the official documentation: SAP Help – Calendar Event API Reference
Below is an example that demonstrates how to batch modify Date context filters for all child events of a process. You can also modify the same script to change other dimension context filters also.
Suppose your planning calendar has multiple child tasks for FY2022.
You now want to update all these tasks to FY2025 automatically.
To view the event ID of an event, go to the Event Settings dialog and choose Show Details.
Then, paste the following script:
// Step 1: Get main process event
//Replace XXXXXXX with Process Event ID.
var root = CalendarIntegration_1.getCalendarEventById("XXXXXXXXXXXXX");
if (root === undefined) {
Application.showMessage(ApplicationMessageType.Warning, "Invalid event ID.");
Application.hideBusyIndicator();
return;
}
// Step 2: Check event type
if (root.getType() !== CalendarTaskType.Process) {
Application.showMessage(ApplicationMessageType.Warning, "Only Process type events can be modified.");
Application.hideBusyIndicator();
return;
}
// Step 3: Get children
var process = cast(Type.CalendarProcess, root);
var childIds = process.getChildren();
console.log("Child event IDs:");
console.log(childIds);
var targetYear = "2025"; // Enter Target new year for the child event
// Step 4: Loop through each childs
for (var i = 0; i < childIds.length; i++) {
var childId = childIds[i];
console.log("Processing child ID"+childId);
var ev = CalendarIntegration_1.getCalendarEventById(childId);
if (ev === undefined) {
console.log("Skipping invalid child->"+childId);
continue;
}
// Step 5: Get context filters
var ctx = ev.getContextFilters();
console.log("Context filters for child:");
console.log(ctx);
// We can’t assign null → use flag and index instead
var hasDateFilter = false;
var dateFilterIndex = -1;
for (var j = 0; j < ctx.length; j++) {
var f = ctx[j];
if (f.members && f.members.length > 0 && f.members[0].dimensionId === "Date") {
hasDateFilter = true;
dateFilterIndex = j;
break;
}
}
if (hasDateFilter === false) {
console.log("No Date filter found for"+childId);
continue;
}
var dateFilter = ctx[dateFilterIndex];
console.log("datefilter");
console.log(dateFilter);
// Step 6: Remove old Date filter for the child event
var removed = ev.removeContextFilter(dateFilter);
if (removed === true) {
console.log("Removed old Date filter for -> " + childId);
} else {
//console.log("Could not remove Date filter for:", childId);
continue;
}
// Step 7: Build new Date filter dynamically
var modelId = dateFilter.members[0].modelId;
var hierarchy = dateFilter.hierarchy;
var newDateFilter = ArrayUtils.create(Type.CalendarContextFilter);
newDateFilter = [{
hierarchy: {
id: "FYQP",
description: "FYQP"
},
members: [
{
dimensionId: "Date",
id: "[Date].[FYQP].[Date.FISCAL_YEAR].[" + targetYear + "]",
description: targetYear,
displayId: targetYear,
modelId: modelId
}
]
}];
// Step 8: Add the new Date filter
ev.addContextFilter(newDateFilter[0]);
console.log("Added new Date filter (" + targetYear + ") for" + childId);
}
// Step 9: Done
Application.showMessage(ApplicationMessageType.Success, "Date context filters updated successfully for all child events!");
Application.hideBusyIndicator();
API Methods Used
| Method | Purpose |
| getCalendarEventById() | Fetches a specific event using its ID |
| getChildren() | Retrieves all child events under a process |
| getContextFilters() | Returns all context filters for the event |
| removeContextFilter() | Removes an existing context filter |
| addContextFilter() | Adds a new context filter dynamically |
Summary
The Calendarevent API in SAP Analytics Cloud provides a rich set of methods that go well beyond modifying context filters.
You can reuse the same structure to perform a variety of automation and maintenance actions across the planning calendar events.
By combining UI-based editing and scripting automation, SAC administrators can achieve both flexibility and efficiency in managing planning calendars.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 18 | |
| 16 | |
| 14 | |
| 13 | |
| 9 | |
| 9 | |
| 9 | |
| 9 | |
| 8 | |
| 8 |