When building an expression for the DataTable.Select method, I found the .Net DataColumn.Expression syntax that clarifies the use of a range of characters e.g. ’ and ". However, can someone point me at the relevant documentation for UiPath specific syntax, for example when using the DataTable.Select method you need to use “+” before and after a user defined variable. Also, the equivalent documentation for UiPath dynamic selectors if you set them up manually.
I prefer using String.Format
filterExpressionTemplate = "[MyField]='{0}'"
and later or just after
filterExpression = String.Format(filterExpressionTemplate, MyVariable)
qry = MyDataTable.Select(filterExpression)
That way, the filter can be read easily and you can apply all cleaning if needed for the variables before “inserting” them into your filterExpression.
Thanks for the quick reply. A different way of thinking about it. Many thanks I will try it out.
Thank you for your previous help on this. I have built a simple sequence to test out your filterExpression approach. It all works fine when I use a literal as the value of MyField in your example, but when I want to use a variable for [MyField], it sees the variable name rather than the value of the variable. The variable I am passing in is a value for column name rather than the literal column name. I have played around with various syntax changes using +'s and single quotation marks, but not yet managed to get it to recognise that I am passing a variable rather than the column name value itself. xaml attached.
Main.xaml (24.9 KB) Any assistance much appreciated!
Main.xaml (18.0 KB) This xaml just has the filterExpression sequence.
If you want to use extra variables, you should adapt both the template and the format
filterExpressionTemplate = "[{0}]='{1}'"
filterExpression = String.Format(filterExpressionTemplate, SelectedColumn, MyVariable)