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

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;
});

Related

Using popup to select correct relational field and pass value back to an entry form

I am using Google App Maker with Cloud SQL to build an asset tracking database.
I have a couple tables with relations:
Asset List (Many to One with locations)
Locations (Many to One with Districts)
Districts (Many to One with Areas)
The issues is when populating new related location fields in an data entry form is that several districts may have locations with the same name. When using the standard drop down the same values appear and there is no way for the user to know which district the location is associated with.
Example: On the asset entry form drop down locations show:
- Shop
- Crew 1
- Crew 2
- Shop
- Crew 1
- External Vendor
I have 2 pages:
Assets - Datasource: Assets table
Entry form Datasource:inherited(assets) to enter new assets
Table View Datasource:Inherited(assets) to see asset that get entered )no edit)
Locations Pop-up
This seems to work as expected basically forms to navigate to correct Location and store it in a text box and a button with the On_Click property to send the textbox value to the data entry form on assets (not working) I can pass the value to a widget but can't figure out how to save it to the actual data source.
Currently using the location in the text box on this form should i be using Id?
I created a pop-up form which lets the user navigate to the correct location record ID by filtering on district. I am having trouble understanding how to actually write it back to the correct location field on the asset entry form. I am new to Java Script/Apps Script so the meaning of all the properties and how to use them is giving me trouble.
I tried setting a text box named SetLocation in the entry form and setting the value property to
#datasource.item.Location.Location
Then in the popup I set the button on_click to
app.pages.Assets.descendants.SetLocation.value =
widget.parent.descendants.PassLocation.value;
Pass Location is the name of the textbox on the popup where the correct location is stored.
Some suggestions to consider. In your popup set a dynamic property, call it 'CreateDatasource' or whatever suits your needs.
In your assets page form where you navigate to your popup (lets say it's a button that opens the popup from your form) put the following code:
var popup = app.popups.YourPopup;
popup.properties.CreateDatasource = widget.datasource;
popup.visible = true;
Lets say your popup content datasource is set to Locations, and your popup has some inputs that filter your locations and then there is a table that displays your filtered results. In this table you would select the appropriate location row and then your popup has a button that passes the location back to your asset form, with code like this:
widget.root.properties.CreateDatasource.item.Location = widget.datasource.item; //this would set the relation only assuming your asset relation end to locations is named 'Location'
widget.root.visible = false;
This would work assuming everything is set up correctly in your relations.

Select all Rows in Dynamics CRM Grid

Lets say I have a Grid in CRM showing me Invoices which need to be created by using a custom javascript dialog. In this dialog I want to put two options which are doing the following:
1) selects all Rows flagged as selected in the Grid
2) selects all existing Rows in the Grid
Particularly I have an issue with No. 2)
I cannot figure out how to get all rows if I have lets say 5 pages of invoices. So how can I select all rows in the Grid and not only those shown on the actual grid page?
Any advice is highly appreciated.
Regards
Sandro
If you want to retrieve only the elements that are selected in a grid, then you can use the Ribbon Workbench to configure a new button on the sub grid. The Button must have a Command Action which can be configured to pass selected items to a JavaScript method using the SelectedControlSelectedItemIds parameter
There is a SelectedControlAllItemIds parameter too, but I think this only gives "All Items" in the current page, not all pages. Not sure about these last bits so definitely worth a try
If that doesn't work, then you will have to do this yourself using a WebApi call. For example, to get all Contacts associated with an Account, you might do something like this:
// Get the ID of the parent account
var accountid = {AccountId};
// Execute a query to retrieve all Contacts associated with the given Account ID
Xrm.WebApi.retrieveMultipleRecords("contacts", "?$select=contactid&$filter=_parentcustomerid_value eq " + accountid)
.then(
function(results) { console.log(results); },
function(error) { console.log(error); }
);
Read more about retrieveMultipleRecords here

Showing all the possible values of a field in App Maker dropdown

I need to create a filter which gets all the possible values for a concrete field, but I'm only getting the values which appears in the current page.
Result
What can I do to get all the values?
It looks like you want to filter table basing on value in the dropdown. In order to do this you need to bind your dropdown's value to datasource's filter:
#datasources.MyData.query.filters.Country._equals
then you need to reload your datasource every time when user changes dropdown's value
// onValueEdit
app.datasources.MyData.load();
You can play with this sample app to learn more: https://developers.google.com/appmaker/samples/project-list/

How do I push an object onto the dataLayer

I'd like to use object in the atalayer. I've followed the developer docs and they show a flat data model. I'd like to push a lead object and update it as a user enters info into a Lead form.
with company, size and location, key and value.
dataLayer.push({'event': 'company_on_blur'}); //on leaving a company field
dataLayer.push('lead.company', '<company>');
dataLayer.push('lead.size', '<company-size>');
dataLayer.push('lead.size', '<company-location>');
dataLayer.push('lead.key', '<value>');
Is there a way to push all this data as a structured lead object?
onclick="dataLayer.push({
// lead data object
});
also how can I modify just one property of an object once it is pushed
dataLayer.push({'event': 'company_on_blur'}); //on leaving a company field
dataLayer.push('lead.company', '<company>'); //update the value in the object
Yes, you can push several values at once with dataLayer.push. It will become something like this:
dataLayer.push({
'event': company_on_blur,
'lead.company': company,
'lead.size': company-size,
'lead.location': company-location,
'lead.key': value
});
To update a value in object on a given event - just use the event as a firing trigger (Fire tag X when custom event equals company_on_blur).
If your idea is to get a fields values from a form and send them to GTM - it's easier to create the variables for the values extractions, create the trigger company_on_blur and fire a tag for collecting the data. You can use also a form submit click as a trigger instead of leaving the field, if you are ok to collect these only for people which clicked the submit button. This way you will collect all data at once.

Checkboxes and View Based Table View

I am having some difficulty trying to use checkboxes as the selectedIndex in a view based table.
There is good documentation on view based table here:
[View Based Tables ]
However, I after searching and looking on Stackoverflow I can't seem to get my implementation for doing the following.
My view is a table that makes a callout to Yahoo Finance. The table is view based constructed with bindings.
When the table is populated I want to have a check box against each row so that when the user clicks the check box, that row will be updated from Yahoo. Currently this works using multi or single selection using the table view and an observer.. I want to do this with the checkboxes and a button that gets all the checked rows.
The IB setup is as follows:
What is the best way to get the rows where the checkbox is selected? Should I use the array controller or do I need to do something with the table?
Assuming that you use a NSArray of NSDictionaries as your data model, why not add a key/value pair to each "stock" dictionary as a flag? Then in your button action method, just iterate through the data model and trigger an update when the flag is set. Bindings do the rest!

Resources