EnumerateObject

Estimated reading: 5 minutes 1976 views

This activity helps the user to retrieve the list of files and sub folders from the specified directory in the connected SFTP server. It must be used within a scope activity

Properties

INPUT

RemoteDirectoryPath: *This parameter specifies to provide the directory path from where the details need to be retrieved. It accepts input values in “String” datatype. You can either hardcode the values in “String” format or provide the value in String” datatype.

MISC

DisplayName: Displays the name of the activity. The activity name can be customized, which aids in troubleshooting.

SkipOnError: Specify the “Boolean” value as “True” or “False.”

True: Continue executing the workflow regardless of any errors thrown.
False: Halt the workflow if it encounters any errors.
None: If the option is left blank, the activity will, by default, behave as if “False” were chosen.

Version: It indicates the version of the feature being used.

OPTION

SubFolder: This parameter can be utilized when there are sub folders available in the specified directory. Check with option to retrieve the list of files from the sub folders also. 
When left empty, it will not be considered. 

OUTPUT

Files: It helps you to view the output of the activity as the list of files’ details retrieved from the specified folder. It returns values in “FileObject” datatype. It contains the following details,
1. Name
2. Size
3. LastModified
4. Permissions
5. IsDirectory 

Result: This parameter allows you to view the execution status of the activity and returns a value in “Boolean”.
True: Indicates that the activity has been executed successfully without any errors.
False: Indicates that the activity has been unsuccessful due to an unexpected error being thrown
.

* Represents mandatory fields to execute the workflow.

Here’s an example of how the activity is used in the workflow:

In the following example, we check if the specified directory exists on the SFTP server. I have used our SFTP server for this demonstration, but you can automate it with your own SFTP server.

1. Create a solution as “Backup”.
2. Install the “SFTP” feature from the “Manage Features” option.
3. Drag and drop the “SFTP Scope” activity into the workflow and set it as the start node.
a. This activity will authenticate the provided credentials and establish a connection to the SFTP server.
b. Enter the SFTP credentials, including the “Host Name,” “User Name,” and “Password,” in their respective fields.
4. Add the “EnumerateObject” into the body of the “Sftp Scope” activity.
a. Now, provide the “RemoteDirectoryPath” in the property as the path from the SFTP server from where the list of files needs to be retrieved.
b. Here it is as “/SampleTest/”.
5. Now, navigate to the “Files” in the output section of the property to declare and view the output.
a. Click on the property as “Files” and provide the variable name as “List_files” and press “CTRL+Q” to create the variable.
b. Now, navigate to the variable section in the designer and click on the “Create variable” option.
    i.  Provide the variable name as “Sample”.
   ii. Click on the “variable type” and choose the “Browse for types” option.
  iii. Now, in the search area, provide the name as “Robility.SFTP.FileObject” and click on “Ok” button.
6. Add the “ForEach” activity into the body of the SFTP scope activity.
a. Here we are choosing this activity to iterate and retrieve each file in the specified directory.
b. Choose the “Type Argument” as “FileObject”.
c. Provide the value as “List_Files”.
7. Now, add a “Writelog” activity into the ForEach scope activity.
a. Here we are choosing this activity to iterate and print the name of each file in the specified directory.
b. Provide the input value as “Item.Name.ToString”.
     i. To retrieve the name of each file, we have provided the value as “Name” near Item variable
     ii. To retrieve other properties details, you can add the property name along with the “Item” variable” as follows,

Item.LastModified.ToString – Retrieves the last modified date of the item.
Item.Size.ToString – Displays the file size from the list.
Item.Permissions – Provides the permissions assigned to each file in the specified source folder.
Item.IsDirectory.ToString – Determines whether the listed item is a directory.
8. Save and execute the workflow. 

The bot will retrieve all the files from the specified directory in the connected SFTP server and prints the name of each file in it.

Files & Folder Permissions Explanation

When retrieving the permissions for a list of files/folders, the following outputs represent the permissions:

1. rw-r–r– (Readable by everyone)
Owner (rw-) → Read & Write
Group (r–) → Read-only
Others (r–) → Read-only

2. rw-rw—- (Owner and Group only has access)
Owner (rw-) → Read & Write
Group (rw-) → Read & Write
Others (—) → No permissions

3. rw——-(Owner only has full control)
Owner(rw-) → Read & Write
Group (—) →No permissions
Others (—) → No permissions

4. rwx——(Owner only has full control)
Owner (rwx) → Read, Write & Execute
Group (—) → No permissions
Others (—) → No permissions

Share this Doc

EnumerateObject

Or copy link

CONTENTS