Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
johannes_huhn
Product and Topic Expert
Product and Topic Expert




Introduction

In fact, SAC's calendar provides an integration into Analytics Designer. Analytic Applications can easily interact with SAC calendar processes and workflows via API. Moreover, Analytic Applications can programmatically participate in workflows to submit, approve or even reject SAC calendar events. Next to that, an Analytic Application can even create new workflows directly into the SAC calendar. The scenario in the video shown below will explain the capabilities along one scenario of Human Resources planning.

 



Video



Check out more enablement material here!
13 Comments
Gabs
Explorer
thanks Johannes for this blog.

If I well understood you were able tocreate a new composite task in the calendar "on the fly" when you created a new position.

Is there any possibility for you to share the script used in Analytic designer please ?

Thanks in advance
avsalynin
Active Contributor
0 Kudos
maybe this video will help you, starting at 06:41 about the Calnedar API script

Planning Process with Analytics Designer
johannes_huhn
Product and Topic Expert
Product and Topic Expert
0 Kudos
Great you appreciate the content. I pasted the code snippet below to start a new workflow:
var newTask = CalendarIntegration.createCompositeTask({
name: "Approve new Headcount",
startDate:new Date(Date.now() + 10000),
dueDate: new Date(Date.now() + 259200000), //+3 days
workFiles: [{ //one single file, the current opened file
//id: Application.getInfo().id,
id: '99183002E75E0E06CD6D1CE0193D526B',
type: CalendarTaskWorkFileType.AnalyticApplication,
}],
//each user is a string
assignees: ["SMILLER" , "MYUSER"]
});
Gabs
Explorer
0 Kudos
thanks Aleksey !!!
Gabs
Explorer
0 Kudos

thanks Johannes. In the meantime I finally found a way and did that script and added 2 rounds for reviewers. I also added a "non member by email" but I don't ubderstand how it works. The non member received the email but he still needs an SAC access when clicking the link received by email.  Unfortunately, we cannot add viewers for the moment :

CalendarIntegration_1.createCompositeTask({
name: "newCompositeTask 1",
startDate:new Date(Date.now() + 10000),

dueDate: new Date(2022, 0, 16, 0, 0, 0),
workFiles: [{
id: Application.getInfo().id,
type: CalendarTaskWorkFileType.AnalyticApplication,
}],
assignees: [Application.getUserInfo().id],
description: "Calendar Composite Task description",
reviewers: {
"1": ["USER1", "xyz@gmail.com"] // email is a non member
,
"2": ["USER2"]
}
}, {
autoActivate: true
});
jannis
Explorer
0 Kudos
Thanks Johannes for your video it was really helpful!

 

I am looking for a way to get the names of the assignees and reviewers through the Calendar API but I can't find the proper API statement for that.

Seems like you can create a Composite Task but what about if you have an already created Composite task (via your calendar) and just want to see the assignees and reviewers in your Analytic Application? Essentially I want to have the same information as when I click calendar toolbar->details where I can see the people involved.

 

Best Regards,

Ioannis
former_member787390
Participant
0 Kudos
Dear Johannes,

 

Is there a way to pass with API the context ?

I have an application where projects will be created and we need to create a task for each project. We successfully tested the api to create a task in calendar from analytic designer but we would like the person who will approve (reviewer of the task) could reach the right project when clicking for approve or reject.

Eg : we created a task with API to approve or reject the project ABC123. When the reviewer wants to approve, it should see only the project ABC123 and not an report where all project are displayed.

 

Best regards
nasser_itani
Participant
0 Kudos
Hello Anthony,

Question is how did you manage to create the task and submit it at the same time from the application.

As per my understanding that you need to open the application from calendar so you will have the ability to submit. Otherwise it will gives an error.

Thank you.
former_member787390
Participant
0 Kudos
Hello Nasser,

What we did is to add at the end a task.submit

We had also some errors I suppose it is because creation sometimes creation is not finished yet when we submit it through the script.

CalendarIntegration_1.createCompositeTask({
name: "newCompositeTask 1",
startDate:new Date(Date.now() + 10000),

dueDate: new Date(2022, 0, 16, 0, 0, 0),
workFiles: [{
id: Application.getInfo().id,
type: CalendarTaskWorkFileType.AnalyticApplication,
}],
assignees: [Application.getUserInfo().id],
description: "Calendar Composite Task description",
reviewers: {
"1": ["USER1", "xyz@gmail.com"] // email is a non member
,
"2": ["USER2"]
}
}, {
autoActivate: false
});

Application.hideBusyIndicator();
Application.showMessage(ApplicationMessageType.Success,"Your task " + name + " has been successfully created ! ");

newTask.activate(false);
newTask.submit();

}

hope it helps

 
nasser_itani
Participant
0 Kudos
Hi Anthony,

I tried the above but still showing the same error that it needs to be opened through the calendar.

by newTask in code you mean the composite task right ?

 

Thank you.
former_member787390
Participant
0 Kudos

Yes a composite task the one created in the script.

JefB
Active Contributor
0 Kudos
Hi johannesnicolas.huhn , mat74 ,

Is there alread a solution to passing context filters from a (API created) CalendarTask to open a pre-filtered application/story workfile?

We want to pass a URLparameter (those starting with p_ in application designer).
Or perhaps a story filter as context.

 

e.g. we want analytics designer to generate a bunch of tasks and then centrally monitor data collection (e.g. to ten's of sales manager responsible for a certain region or customer group). Instead of manual process to generate them with calendar task wizard.
Sonam9
Newcomer
0 Kudos

Hi Johannes,

I would like to understand following:

I can create the Composite task on the fly in the Story however, To submit and Approve the code is not throwing error upon button onclick :

1.

Submit :

var calendarTask = CalendarIntegration_1.getCurrentTask();
var isAssignee = calendarTask.hasUserRole(CalendarTaskUserRoleType.Assignee);
var calendarTaskStatus = calendarTask.getStatus();
var calendarTaskType = calendarTask.getType();
if (isAssignee && calendarTaskType === CalendarTaskType.CompositeTask && calendarTaskStatus === CalendarTaskStatus.InProgress)
{
var compositeTask = cast(Type.CalendarCompositeTask, calendarTask);
var isSuccessfullySubmitted = compositeTask.submit();
if (isSuccessfullySubmitted) {
console.log("You have successfully submitted your task.");
} else {
console.log("Sorry, something went wrong.");
}
}

2.

Approve:

var calendarTask = CalendarIntegration_1.getCurrentTask();
var isReviewer = calendarTask.hasUserRole(CalendarTaskUserRoleType.Reviewer);
var calendarTaskType = calendarTask.getType();
if (isReviewer && calendarTaskType === CalendarTaskType.ReviewTask) {
var reviewTask = cast(Type.CalendarReviewTask, calendarTask);
var isSuccessfullyApproved = reviewTask.approve();
if (isSuccessfullyApproved) {
console.log("You have successfully approved the task of the assignee.");
} else {
console.log("Sorry, something went wrong.");
}
}

3. Is it possible to add context filter like it can be done from Generate Events Widzard in the Context?

 

Thank you