Access value from a list row from a script in App Maker - google-app-maker

In my main data input in my Google App Maker app, I have relation data that's displayed in a list. I want the entries in that list to be able to be null until the user takes a specific action by clicking on a particular button, but at that point, I want the existence of values to be validated.
For the life of me, I couldn't figure out how to access iterate through the rows in the list and check the value of a specific field. But after a TON of trial and error, I figured it out -- see below.

Starting with the list widget (MyList), get the rows contained in it:
var rows = MyList.children._values;
To access the widgets in an individual row, identify them as an array first:
var widgets = rows[0].children._values;
Then get the value of the widget you want by identifying by index:
var value = widgets[0].value;

Related

GSuite Appmaker - how to set default value in table using button

I am trying to put together a mock up for a data collection app for a local nonprofit using GSuite's AppMaker. So far I really like the tool.
One thing I need to be able to do is streamline the data entry for the site representatives. In my app, I display a list of students in a table, where one of the columns is a boolean value which represents attendance. The desired result is for the teachers to be able to input the date field one time using the date input button at the bottom of the page. Then they can quickly point and click down the Present column to log attendance.
My question is: how would I link the date selector dropdown so that the date field pre-populates with the selected date from the input field? I don't want them to have to enter the field over an over again since its the same for each row and I don't want the user experience to feel clunky.
Screenshot of the App for reference:
Using client script, you can add the following to the onValueEdit event handler of the date widget at the bottom.
var items = widget.root.descendants.<YourTable>.datasource.items;
items.forEach(function(item){
item.<DateField> = newValue;
});
The only thing to take into account is that when using client scripting, you will only update the records loaded in the table at the moment; i.e, if your table has paging, it will only update the current page. If you are using paging, then you will need to add the following code to the onPreviousClick and the onNextClick event handlers of the pager widget:
var selectedDate = widget.root.descendants.<YourDatePicker>.value;
var items = widget.root.descendants.<YourTable>.datasource.items;
items.forEach(function(item){
item.<DateField> = selectedDate;
});

Blueprism - Extract data from a web page into a collection

I am new to blue prism. I have a scenario where I am giving input (passengers details for traveling) to a travel portal and based on the input its generating a booking reference number, total cost etc. Now I want to read all the outputs into a collection but the problem is data is not tabular (cant use Get Table in read component). Its just the details of travel which are populating into textboxes. Please find attached the screen shot to have more clarity on this.
How to achieve this? Any leads will be appreciated.
Based on the screenshot you've provided, this is part of the Blue Prism Advanced Consolidation Exercise ("BPTravel").
"Get Table" won't work on this data because it is not a table. As you've mentioned, the data is presented in a series of textboxes.
The way to tabularize this data would be to create a Collection in your Process and manually define each of the Field Names in the collection, then read each text field in individually to the correct column in the collection.
Read each text box data into data item. Create a named collection (i.e Collection with pre-defined column name). Loop through the collection.column_name(You will be getting column name as collection by using Utility - Collection Manipulation action and get the column names) and first add a row to collection and assign values to collection fields

Dropdown from values of a database field

I have an issue related to the data filtering. I have a Google Drive table to store data, and I want to show one field of this data source in a dropdown to make a filter by this field (Country).
The problem is that this dropdown filter it's only showing the countries that appears on the current page of the list. For example, if in the first page appears one country (Thailand) on the dropdown I'll only see Thailand.
If we move to the second page of the list we have another two countries (Spain and Portugal) and then the dropdown will only show Spain and Portugal.
What I really want is a dropdown which shows all the countries, no matter if they aren't on the current page, but I don't know how to fix it. ​
​This the the configuration of the Country Selector:
In the help, it's said we should use #datasource.model.fields.COUNTRY.possibleValues,
but if I use this paramater as Options, nothing is displayed in the selector.
I have spend a lot of hours trying to fix this issue and I don't find the solution, and I would like to check with you if it's an issue or I'm doing something wrong...
Could you help me?
You are using the same datasource for your dropdown and table and by #distinct()#sort() you are filtering items that are already loaded to browser (opposed to the whole dataset stored in database).
You need to have a separate datasource for your dropdown. There are at least three techniques to do this:
Possible values
You can predefine allowed values for your Country field and use them to populate drop down options both in create form and table filtering #datasource.model.fields.Country.possibleValues as you mentioned in question:
Create model for countries
By introducing dedicated related model for countries you can get the following benefits:
normalized data (you will not store the same country multiple times)
you'll be able to keep your countries list clean (with current approach there is possibility to have the same country with different spellings like 'US', 'USA', 'United State', etc)
app users when they create new records will be able to choose the country they need from dropdown (opposed to error prone typing it every time for all new records).
your dropdown bindings will be as simple as these:
// for names
#datasources.Countries.items..Names
// for options
#datasources.Countries.items.._key
// for value
#datasource.query.filters.Country._key._equals
Create Calculated Model
With Calculated Model you'll be able to squeeze unique country values from your table. You server query script can look similar to this:
function getUniqueCountries_() {
var consumptions = app.models.Consumption.newQuery().run();
var countries = [];
consumptions.reduce(function (allCountries, consumption) {
if (!allCountries[consumption.Country]) {
var country = app.models.CountryCalc.newRecord();
country.Name = consumption.Country;
countries.push(country);
allCountries[consumption.Country] = true;
}
}, {});
return countries;
}
However with growth of your Consumption table it can give you significant performance overhead. In this case I would rather look into direction of Cloud SQL and Calculated SQL model.
Note:
I gave a pretty broad answer that also covers similar situations when number of field options can be unlimited (opposed to limited countries number).

Row elements validation in Coded UI

I am working on Coded UI for an asp.net web application.
In one of tests I need to validate and verify if the elements of the row are populated right or not.
For instance, suppose my search criteria is such that the Serial Number should start from 001. As soon as I click on Search button my results grid gets populated with all the elements that have 001 in there serial number.
How can I validate that all the elements of the results grid are correct i.e. starting from 001? I know I must use .contains validation criteria.
But what code should I use to run the loop for checking each and every row? in c#.
This answer is heavily dependent upon what you mean by populated right
Is your grid rendering/CodedUI-Defined as a HtmlTable?
If your grid has strict columns you could just ask for the cells matching your criteria.
var cellDef = new HtmlCell(yourHtmlTable);
cellDef.SearchProperties.Add(HtmlCell.PropertyNames.ColumnIndex, "2");
cellDef.SearchProperties.Add(HtmlControl.PropertyNames.InnerText, "YourDynamicValue", PropertyExpressionOperator.Contains);
var matchingCells = cellDef.FindMatchingControls().OfType<HtmlCell>().ToArray();
Assuming your list is somewhat dynamic then you could just validate each entry exists. If you are trying to validate EVERY row, its contents, and formatting. If so you'll just have to cycle every row and ask for each cell according to your criteria.
foreach(HtmlRow row in yourTable.Rows)
{
var idCell = row.GetCell(0);
var decriptionCell = row.GetCell(1);
// your code to match your entries
}

how get item from each cell in grid

I have form with grid. I defined dataStore with 2 columns (text and checkBox). Grid.store = defined dataStore. Second column is editable (you can change selection on each checkBox). I have some button, and when I click it, I want to get info about each cell. Example if have gird:
Name1 true
Name2 false
I want get info col[0].row[0] is equal 'Name1', col[0].row[1] is equal 'Name2'.
I try iterate on dataStore but it has only value which I put them by hand. The value which was changed on grid by clicking on checkBox didn't save in dataStore.. My question is how to iterate on grid, how get info about each cell.
To iterate across a store in Ext3, you can use dataStore.each()
Supply it an anonymous function and the parameter it receives will be the current record in the store. The data in the current record can be read by using record_var.get(field_name).
So, for example:
var dataStore = myGrid.getStore();
dataStore.each(function(rec){
alert(rec.get(field1));
}

Resources