Uipath sharepoint excel file check

I have a sharepoint link , in the folder

A/B/2024
In 2024 folder I have to check if abc.xlsx file is present or not.
Please help me deduce the logic

To check if a specific file, such as abc.xlsx, exists in a SharePoint folder using UiPath, you can follow these general steps. This process involves interacting with SharePoint through the UiPath Microsoft Office 365 activities package, which offers a direct way to work with SharePoint files. Before starting, ensure you have the UiPath.MicrosoftOffice365.Activities package installed in your UiPath Studio project.

1. Configure Office 365 Activity

First, ensure you have set up the Office 365 scope correctly:

  • Office 365 Scope: Use the “Office 365 Scope” activity to authenticate and establish a connection with SharePoint. You’ll need to provide the application ID, directory (tenant) ID, and a client secret or certificate for OAuth authentication. This information is obtained from the Azure portal where the application is registered.

2. Specify the SharePoint Site and Folder Path

Determine the SharePoint site URL and the relative path to the folder where you want to check for the file. In your case, the relative path will be something like “A/B/2024”.

3. Use the “Find Files and Folders” Activity

Within the Office 365 Scope, use the “Find Files and Folders” activity to search for abc.xlsx in the specified folder:

  • Location: Enter the site URL or the ID of the SharePoint site.
  • Query: Use a query string to search for the file. The query can be something like Name:abc.xlsx and specify the folder path if possible to narrow down the search.
  • Drive Type: Choose “DocumentLibrary” since you’re working with SharePoint document libraries.
  • Fields: Specify which properties of the files you want to retrieve. At minimum, you might want the Id or Name to confirm the file’s existence.

4. Analyze the Results

The “Find Files and Folders” activity will return a collection of files that match the query. You can check if this collection contains any items to determine if abc.xlsx exists:

  • Use an “If” activity or similar conditional logic to check if the collection is not empty, indicating that the file was found.
  • The condition could be something like resultFiles.Count > 0, where resultFiles is the variable holding the output from the “Find Files and Folders” activity.

5. Handle the Outcome

Based on whether the file exists, you can then proceed with your workflow accordingly:

  • If the file exists (i.e., the condition is True), you can proceed with operations on the file.
  • If the file does not exist, you can handle this scenario as needed, such as logging a message or sending a notification.

Example Workflow

  1. Office 365 Scope (with authentication details)
  • Find Files and Folders
    • Location: Your SharePoint site URL or ID
    • Query: Name:abc.xlsx (adjust if you have a specific query format for paths)
    • Check the output
  1. If Activity to check the count of found files
  • True path: File exists, proceed with your logic
  • False path: File does not exist, handle accordingly

This approach requires appropriate permissions for the UiPath application on Azure to access SharePoint files. Make sure you’ve configured these permissions in Azure AD and granted consent to access the files and folders in your SharePoint site.

@Ritaman_Baral

check it