Build Your Automation Using Microsoft 365 Cloud SDK of SAP Build Process Automation
- How to use Microsoft 365 Cloud Office SDK Activities
Prerequisites
- A Windows PC
- If you are using a MAC, please install a VDI
- Install and Setup the Desktop Agent
- Save Sales Order Data on your SharePoint or OneDrive.
After completing this tutorial, you will be able to search for an Excel file on SharePoint or OneDrive, download it and store it on your local machine, read Excel data for a given range and send an email via Outlook with the new Excel file as an attachment.
- Step 1
First you will have to check if the external authentication to access Microsoft services is enabled. Otherwise some activities will not be available.
Navigate to SAP Build Lobby. Choose Settings > External Authentication.
If the External Authentication for Office 365 is not listed, contact your company administrator to set it up.
Open Desktop Agent. Once you are connected to the tenant, choose Settings > External Authentication.
The agent receives and shows a list of registration items defined in IRPA Factory.
Select Office 365 Authentication.
Fill out your email address and save.
Each registration item can be registered or unregistered given a user email address.
Select Register button.
In the newly opened window consent for agent to use your ID with the activities.
The confirmation of registration will appear.
- Step 2
Go the SAP Build lobby. Choose Create button.
Select Build an Automated Process.
Choose Task Automation.
Provide a Name for the project, a description and choose Create.
Select the agent version that is registered on your system.
Provide the name of the automation, a description and choose Create.
- Step 3
You will be navigated to the automation editor where you can build your automation. In order to use Microsoft 365 activities, you need to add the Microsoft 365 Cloud SDK to your project.
Choose Settings.
In the Project Properties window, select Dependencies>Add dependency button > Add a Business Process project dependency.
Under Add dependency search for Microsoft 365 Cloud SDK and Add it.
Close the window.
- Step 4
Under Automation Details panel, under Tools look for Select 365online Authentication activity.
Drag and drop the activity into the workflow below Start.
Under Automation Details panel, under Tools look for Select Get Recent Files activity. Drag and drop the activity into the workflow.
Get Recent Files activity lets you retrieve files recently opened.
Select the Get Recent Files activity. In Input Parameters, under filter choose Custom Data.
This Activity generates a log message within the tester and the trace file.
Apply filter to restrict the list of the recent files. In this case you will look for the file which was created by you. In Input Parameters:
- under
fileName
type Orders and select the expression in quotes. - under
createdByMail
enter your email and select the expression in quotes.
- under
Under Automation Details panel, under Tools look for Log Message activity. Add it to the workflow under Get Recent Files.
Select the Log Message activity. n the Input parameters, under message choose
recentList
.Save the automation. Test the automation.
Once the Test is done, go to the Info in Test Console. Copy:
driveID
valuefileId
value
Save it for later.
The
driveID
is the ID of the remote SharePoint Drive where the file is located and thefileID
is the ID of the workbook.Under Automation Details panel, under Tools look for Select Open Workbook activity. Drag & drop it into the workflow.
This activity opens Excel Workbook.
Select the Open Workbook activity. In Input Parameters under
driveID
andpathOrFieldId
provide the value that you have copied and saved.Here you can automate if you would like to copy the values in each step or set up the Input Parameters in Automation. To do that click on the canvas and select Input/ Output under Automation Details.
Under Automation Details panel, under Tools look for Get Range Values activity. Drag & drop it into the workflow.
This activity retrieves the values, formulas or
numberFormats
from the current worksheet.Select the Get Range Values activity. Under Input Parameters in:
- range Definition enter: A1:F11 and select the expression in quotes.
- format choose:
objectsHeadersOnFirstRow
Under Automation Details panel, under Tools look for For Each control. Drag & drop it into the workflow.
Select the For Each control. Under Parameters in Set looping list choose result.
Under Automation Details panel, under Tools look for Log messages activity. Drag & drop it into the workflow inside the For Each loop.
Select the Log Message activity. Under Input Parameters in message choose
currentMember
.Under Automation Details panel, under Tools look for Select Download File activity. Drag & drop it into the workflow outside the For Each loop.
Select the Download File activity. In the Input Parameters:
- under
driveID
andpathOrFieldId
: provide the value that you have copied. Select the expression in quotes. - under
localFilePath
: provide the path of the file which will store the data on your machine e.g.C:\Downloads\Order.xlsx
. Please select the expression in quotes.
- under
Under Automation Details panel, under Tools look for Select Send emails activity. Drag & drop it into the workflow just below Download File activity.
Select the Send Email activity. In Input Parameters under
mailDescription
choose Create Custom Data.Customize the Email:
- Under subject enter: Your list of orders and select expression in quotes.
- Under body enter: Hello, Your List of orders is ready for you. and select expression in quotes.
- Under
toRecipients
add: your email address and select the expression in quotes - Under attachments path: provide the path of the file which will be added to the email message e.g.
C:\Downloads\Order.xlsx
and select expression in quotes.
Under Automation Details panel, under Tools look for Remove File/Folder activity. Drag & drop it into the workflow.
Select the Remove File/Folder activity. In Input Parameters under path provide the path of the file that will be removed once email is sent.
Save your work.
- Step 5
Once the automation is saved and ready you can test it. Choose Test button.
If you have decided to add Inputs in step Build an automation (sub-step 11), you will need to add the values to the in the Automation Details and run the test.
Check your Outlook Inbox to see the email, that was send with the attachment.
Which activity provides retrieves the values, formulas or numberFormats from the current worksheet?