Step-By-Step Guide to use OneDrive 365 Activity to Create a Desired Folder within the OneDrive Application and Move the Same Folder to a Different Location

Let’s see an example to create a folder named NewBookDetails within an already existing folder, Attachments. Once the folder is created, we want to move it inside <<RootDirectory>>\Output folder.

 

Prerequisites:

  • Register the required OneDrive 365 application in Azure Active Directory.
  • Configure the Office 365 application in Automation Studio. You must add the Microsoft Service URL with an option to create a sign-in process. This lets you establish a connection between Office 365 application and Automation Studio to automatically sign in and perform the automation. Here we have configured Office 365 with the name, OneDrive.

 

 

  • Access token to authorize and login to OneDrive 365 application. The access token can be fetched using the Oauth activity. Here, we have fetched the access token using the Client Credential flow type, into an Out argument, Token.

 

To automate the process of creating a folder and moving the same folder to a different location:

  1. Continue with the same automation process workflow where you have used Oauth activity to fetch the access token.

    Or

    Create a new process and use the Reuse Process activity to use the existing Oauth process workflow. Ensure that the Oauth process is published if you want to reuse the workflow. 

    Here we have continued with the Oauth process workflow itself.
  2. Create the following arguments:
    • FolderName- an In argument to save and pass the folder name that you want to create in the OneDrive 365 application.
    • CreateFolderPath- an In argument to save and pass the folder path where you want to create the folder.
    • SourcePath- an In argument to save and pass the folder name (along with its complete path) that you want to move to a different location.
    • DestinationPath- an In argument to save and pass the complete path where you want to move the specified folder.
    • RenameFolder- an In argument to save and pass the folder name to rename the specified folder at the time of moving it.
    • OneDriveCreateOutput- an Out argument to store the result of the Create Folder feature.
    • OneDriveMoveOutput- an Out argument to store the result of the Move Item feature.
    • UserPrincipalName - an In argument to save and pass the UPN to grant the application permissions.

NOTE:  

In the Oauth activity, ensure to set the Scope to file.ReadWrite.All  permission to enable Automation Studio with the required permission to use OneDrive 365 application.

 

  1. From the Canvas Tools panel, add Application activity to the Flowchart designer.
  2. In the Application Type list, select Office365.
  3. In the Select an Application list, select the configured Office 365 application, OneDrive.

 

 

  1. Drag the OneDrive 365 activity and drop inside the Office365 Application block.

 

 

  1. In the Access Token list, select Token argument.
  2. In the Feature list, select Create Folder.
    1. Click the   (Setting) icon to configure the input configuration. The Input Configuration screen appears.
    2. Define the mandatory options:
    • Corresponding to the Folder Name parameter, select FolderName argument in the Workflow Arguments list to pass the desired folder name as per your requirement. 
    • Corresponding to the Conflict Behaviour parameter, select fail or rename as per your requirement. Here, we have selected fail that signifies create folder features aborts the operation if a duplicate folder is encountered at the specified location.
    1. Define the advanced options:
    • Click Advanced Options and select Item Path
    • Corresponding to the Item Path parameter, select CreatefolderPath argument in the Workflow Arguments list to pass the location where you want to create the desired folder.

    1. Click Confirm.
  3. In the Output list, select OneDriveCreateOutput to store the result of the Create Folder operation.
  4. Select IsClientCredFlow checkbox to indicate the OAuth flow type configured in the OAuth activity is Client Credentials. 
  5. In the UserId/UserPrincipalName list, select UserPrincipalName argument.

    To view the Create Folder result in Automation Studio, you can add WriteLine activity. This prints the result in the Studio Console Output tab after you test run the process. 

 

 

  1. Drag the OneDrive 365 activity and drop below the Create Folder OneDrive 365 activity block.

 

 

  1. In the Access Token list, select Token argument.
  2. In the Feature list, select Move Item.
    1. Click the   (Setting) icon to configure the input configuration. The Input Configuration screen appears.
    2. Define the mandatory options:
    • Corresponding to the Item Path parameter, select SourcePath argument in the Workflow Arguments list to pass the folder name (along with the complete folder path) that you want to move. 
    • Corresponding to the Conflict Behaviour parameter, select fail or rename as per your requirement. Here, we have selected rename that signifies Move Item feature renames the folder to be moved if a duplicate folder is encountered at the specified location. You can specify the new name using the Advanced Options. If name is not provided a numeric suffix is added to the existing folder name. 
    1. Define the additional options:
      • Click Advanced Options and select Destination Path
      • Corresponding to the Destination Path parameter, select DestinationPath argument in the Workflow Arguments list to pass the location where you want to move the specified folder.
      • Click Advanced Options and select New Item Name.
      • Corresponding to the New Item Name parameter, select RenameFolder argument in the Workflow Arguments list to pass the name of the folder that must be used to rename the required folder if a duplicate folder is encountered at the specified location.

    2. Click Confirm.
  3. In the Output list, select OneDriveMoveOutput to store the result of the Move Item feature.

  4.  

    Select IsClientCredFlow checkbox to indicate the OAuth flow type configured in the OAuth activity is Client Credentials.


    In the UserId/UserPrincipalName list, select UserPrincipalName argument.
     

    To view the Move Item result in Automation Studio, you can add WriteLine activity. It prints the result in the Studio Console Output tab after you test run the process. 

    You can assign this process to a robot if you want to execute this process outside Automation Studio.
     
  5. Save the process.
  6. Setup the environment and enter the required login details. Since we have used Client Credentials Oauth flow type to obtain the access token, user credential is not required to login to the application.
  7. Perform test run.
    Below are the sample screen shots of the successful automation workflow: 

    Sample Studio Console Output console:



    The BookDetails folder gets created inside the Attachments folder and immediately moves to the Output folder after getting renamed to NewBookDetails