How to add rows to an Excel table inside a loop after the columns are mapped? - power-automate

How to add rows to an Excel table inside a loop after the columns are mapped?
I tried the "Add rows to an Excel table" step, but I can't grab the values from Column1 and Column2 on the "Select" step above.
This should be easy, I guess, but I can't make it.
Thank you,

Your "Select" actions looks like it might be missing something, seems like it will add the whole item to "Column1" and duplicate that for "Column2". If your value is an array but it is not being recognized as so, you can use the "Parse JSON" action, or the json() expression you should be able to select the keys that you want to use for each column.
I might need more details to see the exact issue with your flow, but in the meantime try this:
Parse JSON action
Here the "Initialize variable" will be your blob storage result.
In the Parse JSON, add you blob storage value
In the "Select" action use the body output of the "Parse JSON" action
You should be able to select the specific values you want in your columns
json() expression
The parameter will be your blob storage. In my example is my string variable sown in the image.
Since the "Select" action returns an array as a result, the next step you should use is the "Apply to each" action
The new values mapped in the "Select" action should be available to be used here, if for any reason they are not (it is common for power automate to have issues like this) you can use an expression to get the value
items('Apply_to_each')?['columnName']
Note that the "Apply_to_each" inside "items" will be different if you rename this action.
Then, you'll have your Excel file with all the rows added to the table you selected.

Related

How to read an excel sheet and put the cell value within different text fields through UiPath?

How to read an excel sheet and put the cell value within different text fields through UiPath?
I have a excel sheet as follows:
I have read the excel contents and to iterate over the contents later I have stored the contents in a Output Data Table as follows:
Read Range - Output:
DataTable: CVdatatable
Output Data Table
DataTable: CVdatatable
Text: opCVdatatable
Screenshot:
Finally, I want to read the text opCVdatatable in a iteration and write them into text fields. So in the desired Input fileds I mentioned opCVdatatable or opCVdatatable+ "[k(enter)]" as required.
Screenshot:
But UiPath seems to start from the begining of the Output Data Table whenever I called for opCVdatatable.
Inshort, each desired Input fileds are iteratively getting filled up by all the data with the data stored in the Output Data Table.
Can someone help me out please?
My first recommendation is to use Workbook: Read range activity to read data from Excel because it is quicker, works in the background, and does not require excel to be installed on the system.
Start your sequence like this (note the add headers property is not checked):
You do not need to use Output Data Table because this activity outputs a string containing all row items. What you want to do instead is to access the items in the data table and output each one as a string in your type into, e.g., CVDatatable.Rows(0).Item(0).ToString, like so:
You mention you want to read the text opCVdatatable in an iteration and write them into text fields. This is a little bit more complex, but i'll give you an example. You can use a For Each Row activity and loop through each row in CVDatatable, setting the index property if required. See below:
The challenge is to get the selector correct here and make it dynamic, so that it targets a different text field per iteration. The selector for the type into activity will depend on the system you are targeting, but here is an example:
And the selector for this:
Also, here is a working XAML file for you to test.
Hope this helps.
Chris
Here's a different, more general approach. Instead of including the target in the process itself, the Excel would be modified to include parts of a selector:
Note that column B now contains an identifier, and this ID depends on the application you will be working with. For example, here's my sample app looks like. As you can see, the first text box has an id of 585, the second one is 586, and so on (note that you can work with any kind of identifier including the control's name if exposed to UiPath):
Now, instead of adding multiple Type Into elements to your workflow, you would add just a single one, loop over each of the datatable's row, and then create a dynamic selector:
In my case the selector for the Type Into activity looks as follows:
"<wnd cls='#32770' title='General' /><wnd ctrlid='" + row(1).ToString() + "' />"
This will allow you to maintain the process from the Excel sheet alone - if there's a new field that needs to be mapped, just add it to your sheet. No changes to the Workflow are required.

How to allow user to add information for every fields in forms

i have a strange user request: they want to be able to say for every fields in every forms from where they get information used to compile it.
value must be selected from a list
essentially iam looking a way to avoid to double the fields.
one way can be add a M:M table where link field-name and information-source
but using this for retrive from real data table only fields derived from an info-source can be really bad
EDIT
to be more clear the solution i want to avoid is to have a data table like this:
fieldname1
fieldname1Origin
fieldname2
fieldname2Origin
fieldname3
fieldname3Origin
...
but i do the link table in this way:
FieldName
OriginId
i have to map oll field names and to search in it with string name when i need to query data table i have to do something like this
select
case when (exists select 1 from LinkTable where FieldName='fieldname1' AND
OriginId=SelectedID) then fieldname1
else NULL
end
for every fields
What about mixing several controls, such as a combobox with all lines, that would trigger the display of all columns of that line.
Something like that (I am currenlty working on that project):

Using variables in From part of a task flow source

Is there any way to use a variable in the from part (for example SELECT myColumn1 FROM ?) in a task flow - source without having to give the variable a valid default value first?
To be more exact in my situation it is so that I'm getting the tablenames out of a table and then use a control workflow to foreach over the list of tablenames and then call a workflow from within that then gets data from these tables each. In this workflow I have the before mentioned SELECT statement.
To get it to work properly I had to set the variable to a valid default value (on package level) as else I could not create the workflow itself (as the datasource couldn't be created as the select was invalid without the default value).
So my question here is: Is there any workaround possible in this case where I don't need a valid default value for the variable?
The datatables:
The different tables which are selected in the dataflow have the exact same tables in terms of columns (thus which columns, naming of columns and datatypes of columns). Only the data inside of them is different (thus its data for customer A, customer B,....).
You're in luck as this is a trivial thing to implement with SSIS.
The base problem for most people is that they come at SSIS like it's still DTS where you could do whatever you want inside a data flow. They threw out the extreme flexibility with DTS in favor of raw processing performance.
You cannot parameterize the table in a SQL statement. It's simply not allowed.
Instead, the approach that people take is to use Expressions. In your case, assuming you had two Variables of type String created, #[User::QualifiedTableName] and #[User::QuerySource]
Assume that [dbo].[spt_values] is assigned to QualifiedTableName. As you loop through the table names, you will assign the value into this variable.
The "trick" is to apply an expression to the #[User::QuerySource]. Make the expression
"SELECT T.* FROM " + #[User::QualifiedTableName] + " AS T;"
This allows you to change out your table name whenever the value of the other variable changes.
In your data flow, you will change your OLE DB Source to be driven by a query contained in a variable instead of the traditional table selection.
If you want an example of where I use QuerySource to drive a data flow, there's an example on mixing an integer and string in an ssis derived column
Create a second variable. Set its Expression to create the full
Select statement, using the value of the first variable.
In the Data Source, use "SQL command from variable" option for the
Data Access Mode property.
If you can, set a default value for the variable you created in step
That will make filling out the columns from your data source much easier.
If you can't use a default value for the variable, set the Data
Source's ValidateExternalMetadata property to False.
You may have to open the data source with the Advanced Editor and
create Output columns manually.

BIRT Issue while using MultiSelect List Box

I was supposed to use MultiSelect List Box (Dynamic one) where user can select multiple value (by holding Ctrl key) to see the report.
So while implementing I tried to fetch param value at BeforeOpen method and pass it to DataSet ,append it to where clause using IN operator.I got SQL error on screen. So when I print param value it was something like [Ljava.lang.Object;#26ba26ba] causing error in query. I thought I can't process that multiselect param value in script and pass it to query. So dropped that Idea.
Now I am using BIRT's inbuilt Filter functionality in Data set. What I was doing in SQL using script at Beforeopen Method now i am doing the same in dataset Filter. I used row["dataColumn"]IN param["param"].value and it is working fine. I am able to select one or multiple value from filter screen , execute report and getting proper result.
Now one more thing I need to implement is There should be Select All in filter list box so that instead of selecting any other value user can just select Select All and bring the report for all data. I am passing '%' against Select All. Since I am using IN operator so I am not able to get any data on Report.
I want to provide Select All functionality along with multiselection but not able to do that for above limitations . Alternatively I can use Ctrl+A to select all and it is working also I can do that but this is as per requirement that I need to implement.
I am using BIRT version="3.2.17"
ANY IDEA WILL BE APPRECIATED..Thanks In Advance..:)
Are you able to add a "Select All" option to your parameter choices? I have done this using a union with my parameter query and just adding a 'Select All' to my query results.
Normally what I'll do is add something to my query that will let me easily replace the parameters. Something like:
SELECT myStuff
FROM myTables
/**where**/
You can then modify your DataSet query in your beforeOpen statement.
Something along the lines of:
if(params["myParam"]!='Select All'){
this.queryText=this.queryText.replace("/**where**/","WHERE myStuff IN ('" + params["myParams"].join("','") + "')");
}
This is obviously very simplified, but you should be able to use some form of it to allow what you are asking.

Generate reports in birt using user input. When input is null, everything should be fetched otherwise corresponding data should be shown

I have to create a birt report with user input parameters. It is something like when the para
meter is left blank it should fetch all values from a table otherwise when the user inputs the students roll no.,the corresponding data should be fetched. Can this be done through Birt report? If yes, then please suggest a way.
Thanks!
Yes, you can do that. If the parameter is optional you can't use the Dataset Parameter (with a ? in your query), because it will be null. Instead you have to modify your query using JavaScript.
Create a Report Parameter like usual, in this case 'stud_no'. Then add a comment in your SQL that you are reasonably sure is unique, I use something like --$stud_no$, wherever you want your clause inserted.
Then add a script like this to your Data Set, in beforeOpen:
if (params["stud_no"].value){
this.queryText = this.queryText.replace("--$stud_no$", "and stud_no = " + params["stud_no"]);
}
This replaces the comment with the clause when the parameter has a value. You can use regex in the search string, and then you can also insert it multiple places if you want.
Create your paremater using a like statement
where students_roll_no like ?
Create your report paramater using as a text box, with a defualt value of %
Because the percent '%' is the SQL wildcard, it returns all values. If the user enters a Student Roll number, it returns only that record. Additionally the user can enter 0500% and get all the records that begin 0500.

Resources