How do I fix this? Relation Error - TypeError: Cannot read property - Creating new record: (Error) - google-app-maker

A short description of the issue:
I can't make a new page, 2 data source relation function in my app (which has similar existing pages with relations that work). The new relation always produces the following error on the parent table:
E Fri Nov 08 08:10:55 GMT-700 2019
TypeError: Cannot read property "EkYkTNJF93VWDxnS7Gi1OIIBSsHXTZ7H" from null.
E Fri Nov 08 08:10:55 GMT-700 2019
Creating new record: (Error) : Cannot read property "EkYkTNJF93VWDxnS7Gi1OIIBSsHXTZ7H" from null.
at Apex_Office_Time.Table1Panel.Table1.Button1.onClick:1:19
E Fri Nov 08 08:10:55 GMT-700 2019
Creating new record failed.
I I am always able to produce the error even when I start a new app from a blank template. The error will occur & not show the new record. Yet if I refresh, the record will be there. Existing apps with similar relations always work.
001 Here is the data source relation between the 2 data sources
Here is a newly set up Google cloud SQL data source "Apex_Office_Time"
Here is the Second Data source "Apex_Office_Time_Details"
Here Is the Page "Apex_Office_Time" which contains a table. The blue + button should create a new item on the table. It does when there is no relation between the data sources
Here is a shot that of the page that show the data source for the table is related to "Apex_Office_Time"
Here is the generated preview before I hit the + button
Here is the generated preview after I hit the + button & complete with error code
Here is the generated preview after I hit the + button, and after I manually hit the refresh button on my browser. I get the same results in Chrome, Firefox, & MS Edge
Further points of note:
When I set up a table that generates items for the "many" side of the relationship "Apex_Office_Time_Details", new items for this table are created without issue.
I just added a third data source to the mix "Apex_Office_Test". I then made "Apex_Office_Time_Details" to "Apex_Office_Test" a one to Many relation. I then tested to see if I could create items in "Apex_Office_Time_Details" without issue as before. I was successful. I then tested to see if I could create items in "Apex_Office_Test". I was successful. I then deleted the "Apex_Office_Time" data source and retested the other 2 tables and their data sources. I was successful. It seems very odd, but its working. I am going to continue testing based on this line.
Success! Evidently there is a minimum length for the names in data sources. The number fields "b" & "bh" in the data source "Apex_Office_Time_Details" was the issue. When I deleted them the table worked. Then I tried renaming the fields to "Billed" & "Billable_Hours" and everything seems to be working

Success! Evidently there is a minimum length for the names in data sources. The number fields "b" & "bh" in the data source "Apex_Office_Time_Details" was the issue. When I deleted them the table worked. Then I tried renaming the fields to "Billed" & "Billable_Hours" and everything seems to be working

Related

How to 'Add / Sum / Total / Calculate' dynamic tables in google app maker

It's probably the simplest thing in the world but I can't seem to add/sum/calculate tables in App Maker. I have attached an image of the App preview. I will try to keep this simple. The page has 3 data sources as follows:
Apex_customer_po - This is where our employee's input customer purchase orders including the PO number (string), the overall value of the PO (number), and the details (string)
Apex_customer_po_wo_details - Purchase orders are often broken up by our customer in to multiple work orders (WO), a task break down each with it's own values including Date (date), WO number (string), WO amount (number), details (string)
Apex_customer_po_wo_costing - This is where we keep track of what work we've done and how much of each work order's money we've used. The fields include a reference number(string), parts price (number), Part details (string), Labour hrs (number), Labour rate (number), Total labour (number), and Invoice total (number), Overall total of all invoices for the work order (number)
My data relations are as follows:
Apex_customer_po
Apex_customer_po_wo_details (One Apex_customer_po to Many Apex_customer_po_wo_details)
Apex_customer_po_wo_costing (One Apex_customer_po_wo_details to Many Apex_customer_po_wo_costing)
Shows the general configuration of the PO app preview mode. I includes 2 work orders each with their associated invoices
Shows the general configuration of the Layout view of the app page
I have figured out how to calculate the cost of my labour:
#datasource.item.Labour_total = #datasource.item.Labour_time * #datasource.item.Labour_rate
I have figured out how to calculate the total of each invoice:
#datasource.item.Invoice_total = #datasource.item.Parts_amount + (#datasource.item.Labour_time * #datasource.item.Labour_rate)
But I can't for the life of me figure out how to 'Add / Sum / Total / Calculate' the individual invoices from each Work Order to get a total value.
I've tried unsuccessfully to use reduce and a bunch of other methods, but I can't ever seem to get the syntax correct even on basic 1+1 type calculations. I don't have much experience in app maker but I've been doing fine and loving it... until now.
Update 001:
I have managed to get a reduce function to perform a simple table addition for me based off the following blog post. blog.supportgroup.com/google-app-maker-cold-calculations - And the ball is rolling again. Now I need to rework how my data sources are set-up changing the numbers to strings –
Update 002:
I managed to get the reduce function to work in my app. However it totals the values from the selected cells across the data source. For example I have a PO, lets call it PO#1 and there are 5 items that total $5. When I start a new PO#2, it carries over the total of PO#1. So it calculates the entire data source regardless of the fact that it's 2 different PO#'s and I don't know how to make it stop. The code I have used is as follows
#datasource.item.Total = getFormatMoney((#datasources.Apex_customer_po_wo_costing.items).reduce((b,a) => Number(a.Parts_amount) + (Number(a.Labour_rate) * Number(a.Labour_time))+ Number(b) , 0 ),2,",",".")
The getFormatMoney(),2,",",".") is a client side java script that formats the currency
Thanks in advance for the assistance.
UPDATE 003:
I am now trying to do this in a different way with a calculated Data source and I am following this tutorial:
YouTube 7.33min long - Totals in Drive Tables tutorial
I have re-created the app step by step but I am getting the following error regarding my SQL query code:
E Mon Nov 18 13:38:49 GMT-700 2019 Exception: Malformed SQL. More
information: Error with SQL statement: You have an error in your SQL
syntax; check the manual that corresponds to your MySQL server version
for the right syntax to use near var totals = (wholesale:0, retail:0, profit:0); var records = app.models.autos. at line 1.
E Mon Nov 18 13:38:49 GMT-700 2019 Executing query for datasource
totals: (Error) : Malformed SQL. More information: Error with SQL
statement: You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near var totals = (wholesale:0, retail:0, profit:0); var records =
app.models.autos. at line 1.
E Mon Nov 18 13:38:49 GMT-700 2019 Executing query for datasource
totals failed.
My code in my data source is as follows:
var totals = {wholesale:0, retail:0, profit:0};
var records = app.models.autos.newQuery().run();
records.forEach(function( item ){
totals.wholesale += item.wholesale;
totals.retail += item.retail;
totals.profit += (item.retail - item.wholesale);
});
var record = app.models.totals.newRecord();
record.wholesale = totals.wholesale;
record.retail = totals.retail;
record.profit = totals.profit;
return [record];
Anyone have any thoughts on what the mistake is?
Update 004
Success - The data source type needed to be a "Calculated" type not a "Calculated SQL". Now I am going to see if I can apply this new type of calculation to my existing problem.
It seems like the way to go on this is the calculated model route the tutorial I linked in Update 003 is a solid path to go down.

D365FO Tile count on workspace doesn't work

Situation is next one:
I created several tiles. Every tile need to show count of records.
Tile "Expired Active Contracts" always shows zero.
There is created simple query with data source table Contract. Ranges are added (ContractStatus; Value: 2) and (ValidTo; Value: (LessThanDate(0)) )
When it's clicked on tile, it opens valid form with valid record, where contracts status is active (2) and ValidTo are any date before today's date, but count doesn't working.
Tried to recreate, tried several things but definitely nothing. ValidTo field is date field.
Some time ago I had a mistake very similar to yours in my dev environment, this steps help me to fix the error.
1 - Clear Usages Data.
2 - SysAdmin/Setup/Data cache/Tile data cache configuration. Select
the tiles which are running into this issue and then delete the
selected tiles.
3- In VS rebuilt and Synchronized the Solution.
4 - Finally refresh the Application browser.
Another thing is that a while ago there was a problem for tiles refresh
Issue 243278 Workspace tile does not update correctly when reusing the
same name
https://fix.lcs.dynamics.com/Issue/Details?bugId=243278&dbType=3&qc=68b6dc6804c9cea218daa102968c7acfcdfe6a990e80e0b5ec66b920a680fceb
I hope you find it useful

Powerapps - get stuck with UpdateContext

I am trying to build a PowerApp to log setup times of our machines by our fitters.
This is what my app looks like:
There are buttons named "Uhrzeit". Pressing these will write the current date and time into the Date/Time fields. I am using the following code:
UpdateContext({Total8:(Text( Now(); "[$-de-DE]dd/mm/yyyy hh:mm:ss" ))})
The Date/Time field is named Total8.
The code is working well but after saving the form and opening a new record the old data is still available in the fields. By clicking on the button "Zeiten zurücksetzen" I can "delete" the old data.
UpdateContext({Total8:""})
Problem: When I open one of the older records the old data is not available in the form. There is only the value of the last record. In the Common Data Service where my records are saved the values are correct.
As an example, I am saving this record:
When I open a new record, the values of the record 1 are still available. This should not be the case if my app worked properly.
For your Information:
If I enter the date/time without tapping the button, saving the record and opening a new record I don't have the problem. I think the "UpdateContext" code is not the code I should use here.
Can anyone help me solve the problem?
I don't think there's a problem with using the contexts in this way -- but remember that a context is just a variable. It isn't automatically linked to a datasource in any special way - so if you set it equal to Now(), it's going to keep that value until you do something different.
When you view an old record, you need to get the data from CDS and update your contexts to match the CDS data. Does this make sense?
Yeah thats my problem.
I want the variable to be linked to a datasource. Or is it possible to write the date/time into the fields without using a context variable?

Spotfire Bookmarks issue

I have a dxp file published to Library (Server) having 5 dashboards.
All my filters are created using Document Properties for users to interact
with.
I did the below scenario:
Selected certain values from the Properties so that data gets filtered
in reports.
Did the same in all 5 pages
Created a bookmark
Went ahead and made some more changes to the report. Selected another
set of values/changed the time frame
Did the same ini all 5 pages
Created a bookmark.
Now when I close the Analysis and reopen it, the latest bookmark gets
applied to it by default. (I do not know if this is a feature).
When I click on the older bookmark, only first 2 pages reflect filter
values properly. Rest reflect the New one.
When I re-did this, the last 3 were showing properly. First 2 had proper
time range as well, but the product filters were wrong.
Does anything special need to be done for bookmarks?
Regards,
Subro
The latest book marks are getting applied by default because it's the state where you last saved the dxp. You can click on the first book mark, save the dxp, and this will be what the users see when they open it on a Web Player.
Additionally, You can allow the users to return to the last "view" of the analysis / where they left off if you change this setting:
Edit > Document Properties > Library (tab) > "Remember personalized view for each Web Player user"
It's hard to diagnosis the problem with the filters without seeing the dxp... but i suspect it is because of step 4, "Went ahead and made some more changes to the report". Depending on what you did, this would cause errors. Bookmarks aren't a snapshot of the memory...

Unable to view uploaded timeseries data in UI chart

Running the Databus server from the command line I have successfully uploaded timeseries data via curl, and am able to query the same data with the api. I'm unable to view any of the data in the table in the UI. After selecting "My Databus" -> Tables is says "You do not belong to any groups that have tables yet. Add some groups, then tables!!!". Navigating to the Database and selecting the table -> chart no data comes back there either.
I have noticed that the query it issues is from a recent time range, while the data I loaded is for an earlier time period. Is there a default way to show the most recent data available in a table?
Is your table type relational or stream? If relational, what is the primary key?
If time series, this url will give you the last 10 values because of the parameter 10 and reverse=true.
http://[yourhost]/api/firstvaluesV1/10/rawdataV1/[yourtablename]?reverse=true
If relational table, you can retreive all values like so
http://[yourhost]/api/getdataV1/select+c+from+[yourtablename]+as+c
replace either urls [yourhost] and [yourtablename] values.
We do not use the tables page much. It is better to click in the specific database as in My Databus -> Databases and then click on the database that has your table. We are about to add a view data link in there showing most recent 1000 values or something like that. There is already a view chart which shows most recent 2 hours(again, we want to change that to most recent 1000 data points instead as well).

Resources