I got a question about coding … How do you manage to use Switch statement with datetime format ?
I know how to do it in C# and VB .net but dont manage to use our native activity, let me show you an example :
I have a Switch configured with TypeArgument = System.Datetime
When I try to switch a date (2 days ago in the example) it’s ok but, the problem comes when I try to add cases
Just after adding this, I get an error
I mean, I can use an invoke code but I’m courious about how to solve this in UiPath
Hi @jmedinacarbonell ,
what is your intention with the switch? I think if you use “today.adddays(-2)” as expression, you will always have the case “today.adddays(-2)”. Or do you want to switch in case of how many days is a given date away from today? so the expression would be something like “today - yourdatevariable” and the case would be 0, 1, >3 etc.
Regards
Moritz
As said, its just an example so, yes, your solution is changing the variable to compare with an int32 in order to know the distance in time from today, thats right
My question comes exactly in that point:
Today, when I can, I use switch in this way, I “transform” the variable to analyze in order to have cases in String or int32
There are some cases where I coulnd’t do it, of course, not the case I exposed but close. In those cases, I’m used to place an invoke code, where I can Switch any kind of typeArgument (as used in C#, vb .net, Python, Javascript …)
And here is the point, Im wondering if you guys managed to use Switch activity with other typeArguments, like Datetime, not int32 or String
Hi @jmedinacarbonell,
I didn’t manage to use a swith with other types of arguments. I 've found a solution to do some more complicated expressions by using nested Ifs. It was in a flow switch, but I think it will work in a switch as well:
I’m just changing this topic to Studio feedback just to let it open as feature request untill UiPath team find it interesting to resize the activity with a wider typeAgument list