I am on a workflow, where I am already able to add the list of files in a folder to a orchestrator queue and perform few actions. Now, I have to proceed with the next set of action using switch activity:
For example, suppose there two items (ABC.xlsx and DEF.xlsx) in a folder and these are added to the orchestrator queue. Now, I am reading the file name in the folder and then based on the file name, I have to perform certain action. Example, for the file name with ABC, I have to open ESPN browser and for the file name with DEF, I have to open Netflix browser.
The challenge is to read the file name (ABC) in the folder and then compare it against the queue item (Transaction item 1). If both are same (ABC), then it should proceed with the next set of action - open browser ESPN and perform next set of action.
Hi @Karunamurthy - Trying to understand, whatever the files that folder has, those will be loading to the Orchestrator queue. Then, why again comparing the file name from the Orchestrator queue with the one in the folder.
I guess your process of steps should be like
Get the file name from the Orchestrator queue
Based on the file name perform the actions
If this is you are expecting, you can use switch case in your code the condition should be
I tried as per your suggestion but getting the error “If: Object reference not set to an instance of an object.”. Sharing the screenshot below for your reference. Can you help?
If the file name from the orchestrator queue varies every time, what would be the code. ABC and DEF file name was just an example to explain the requirement. Can you also show the variables to add?
its working once check your strFromQueue.tolower value
or you can use this in if condition Name.Any(function(r) r.Contains(“place here your queue item value”))
Seems pointless to add the queue item, then get it back out and compare it to the file. Why not just read the files, loop through that array, and do what you need to do for each file?
If you have some other reason to create them as queue items and process them later, then just store more than the filename in the queue item. Store the path and whatever other values you need, and process right from the queue item rather than re-reading the files in the folder.
Also, you’re wasting effort creating these variables to assign the values to. Get rid of the Files and Name variables. Just use the System.IO and Path.GetFileName expressions directly in your For Each and Switch.
It might help if you gave us a description of your overall process because it sounds like you’re going through it in a convoluted way.
Correct, I want to compare the transaction item name with the file name in the folder and then need to process file in the folder using switch activity. My actual requirement is to process the files in queue in switch activity.
If there are 2 excel files (ABC and DEF) in the folder, I have moved them to Orchestrator queue and perform certain clean up before the switch activity.
When it comes to switch activity, for each file in the folder, I have different set of action. I want to perform the required action in switch activity in queue. First ABC file should be processed in switch activity and then get the DEF file from the folder and process it. But now both ABC and DEF is getting processed without processing the action in queue.
1)If you see in the above switch activity screenshot, TransactionItem.SpecificContent(“FileName”).ToString this exp represents getting the file name from the queue and then .Equals("ABC.xlsx") exp represents comparing the queue output which is a file name with ABC.xlsx
No, as I mentioned above TransactionItem.SpecificContent("FileName").ToString represents the queue output. Before switch use Get Transaction Item activity and assign the output variable as TransactionItem
That is how, the queue process it, when you are trying to load the files from the folder to queue, it loads the same order as in the folder.
Ex: First ABC file, next DEF file to the queue
So, while retrieving from the queue, it follows the same order. It gets ABC file then DEF file etc. So, I guess again you need not to compare again the queue file name with the file in the folder as the queue gets the filenames in the same order as it is in the folder
Also, can you confirm the file names in the folder will always be same or varies
In my case, ABC and DEF are just an example. If the file name in the folder varies each time when running the automation, what would be Case 1 and Case 2?
Because switch case can be used when you have cases like a,b,c etc …when its changing we only compare…and either put it into case A or B or C or etc
Yes, each file has different task which I will be adding in the switch activity.
The requirement is that suppose there are 10 files in the folder like ABC.xlsx, DEF.xlsx, GHI.xlsx, etc.,. I have added them to queue item, therefore, ABC will be 1st queue item and in the switch activity even though there are 10 different task are configured each file, it should only perform ABC file in the folder as per the queue. Now, 2nd transaction item DEF should be follow the same process. Like wise for other remaining files in the folder as per queue.