I have just started using UI path to create some automation to download files from a portal.
Hitting a hurdle with this specific situation. I want the bot to select the pay period end that has already passed and it needs to do the same till the next pay period ends.
For example, Today is 10/30/2019 which means bot needs to select 10/25/2019. 10/25/2019 needs to be selected until 11/08/2019. And say today was 11/09/2019 the bot should pick up 11/08/2019
Hi
Welcome to uipath community
There are actually two ways to handle this situation
We can use either SELECT ITEM activity in this where select that drop down as a element and so that we could be able to choose the date we need from that by passing the value as a string
Or
If the field takes typing the value and then a enter press key can choose it if possible
Then we can type in the date value as a string input to TYPE INTO activity and followed by that we can use send hot key activity with key as enter
I have been trying this out with select item for sometime today. I am facing difficulty with the string logic.
What logic would I write to select 10/25/2019 as that is the latest period end?
@arsh - There are multiple ways to solve, but I would go about it like this:
Use Find Children activity on the dropdown box and get all of the elements. Iâll call this AllDateElements
Create a List variable (of type string) with an assign activity. Iâll call this AllDateValues. Assign AllDateValues = new list(of string)
Use a for each loop on the AllDateElements (be sure to change TypeArgument to UiPath.Core.UiElement).
a. Use a âGet attributeâ activity. Pass in âitemâ (or whatever you named the variable in the for each loop) in the Targetâ>Element property. Save the output to a string variable Iâll call tempDateValue.
b. Use âadd to collectionâ activity. The properties for this activity are - Item: tempDateValue // Collection: AllDateValues
Create a new datetime value iâll call CurrentDate. Assign CurrentDate = today
In a While loop (NOT a Do While loop) with the condition being: Not(AllDateValues.Contains(CurrentDate.ToString("MM/dd/yyyy")))
a. CurrentDate = CurrentDate.AddDays(-1)
Use a select item activity. Item attribute should be: CurrentDate.ToString(âMM/dd/yyyyâ)
it sounds complicated, but can be accomplished relatively easily in studio and should run in a second or less. Please let me know if you have any questions. If you arenât able to follow the text-only answer like this I could put something together in studio as well - although it wonât be able to be tested since I donât have the same dropdown list of dates available to me
@Dave. Thank you for the detailed response. I have tried to together the steps that you have explained but I could not get it running because of some errors.
Could you review and see if the logic makes sense.
Find Children - the output is in quotes. This needs to be output to a IEnumerable<UiElement> type variableinstead
AllDateValues - this is currently a string variable. It needs to be a List type variable instead
The first for each needs to iterate over AllDateElements, not the AllDateValue variable
Get Attribute - You need to specify the attribute. This is the name of the attribute you want, it can be found using UiExplorer. Iâm guessing you want âinnertextâ but am not 100% sure, you will have to confirm that yourself.
Get Attribute - you need to save the output result to a string variable. Right now you typed in tempDateValue but you need to create a string variable with the same name
Add to collection activity - I was trying to help with the attributes. When i typed item: tempDateValue that meant in the item property, you should put tempDateValue. I have updated this.
Add to collection activity - the TypeArgument needs to be string
Assign CurrentDate - you need to create a DateTime variable to store this in. You never declared it.
Assign CurrentDate - this needs to be done outside the for each loop.
While loop - your condition wasnât valid because it was missing the final close parenthesis )
While loop - you forgot to put in the assign activity for CurrentDate = CurrentDate.AddDays(-1)
Select item - this should not be in the while loop, it must come after the loop
Select item - you need to put in the CurrentDate.ToString(âMM/dd/yyyyâ) as the item you are selecting
I removed excess sequences that werenât being used.
NOTE: I did not verify or validate any of the selectors you are using. You are responsible for making sure the selector used in the âfind childrenâ and âselect itemâ activities are correct
First you have to write a logic to get the Date, like it will be get todayâs date and add 15 days if its sunday add +1 or something like that, and when you get the final date which you have to select as a string then use select item options.