If statement with drive item

Hello,

I have a find files and folders activity, and would like to say if this drive item has a specific name do this

Please find the logic below:

The issue I am having is with the IF statement:

I am unsure how to configure the above

sound more like you want to check if within the returned collection of drive items a drive item with a particluar name is present. Is our understanding correct?

Hi @E.T.S

In the If Condition Put this

YourDriveItem.Name=“TemplateNameHere”
Then
// your logic
Else
//

Hope this helps

That’s correct! So if the file has a particular name - go down the then branch in the IF statement

Hi @sanjay3

The above logic returns the following error:

image

Hi @E.T.S

  1. Please give input in your Find Files and Folders activity
  2. Store the output in a variable (for eg:- SearchedFile)
  3. Use If Condition
    SearchedFile.Name="XYZ
    Then
    // your logic
    Else
    //

Hope this helps

I have given the input and stored the output in a variable, however am getting the same error in the if condition:

@E.T.S

try like this

diDocumentsFiles(0).Name.Equals("Nametocheck")

diDocumentsFiles - this is array of drive items

if you create variable in first then you will get only one

Also better to check first if any items are returned

diDocumentsFiles.Coun>0 AndAlso diDocumentsFiles(0).Name.Equals("Nametocheck")

cheers

That works thanks!

Would the (0) mean the first thing is checked in the output though

@E.T.S

yes that is correct…added explaination above

cheers

Thanks!

Would I use diDocumentsFiles.Coun>0 in an assign? I am unsure how to implement that

@E.T.S

use above as is in if condition

this will first check if atleast one item is received and then checked received item name is equal to given name

Hope this helps

cheers

diDocumentsFiles.Any(Function (x) x.Name.equals("Template name here"))

it will check all items from returned collection if there is any DriveItem present having this name

Does this mean I won’t need a for each

when the intention is about to check

then we can do it within this one liner without looping over all item with a for each

Thank you this works!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.