Search code examples
powerappspowerapps-canvasdataverse

PowerApps DataVerse storing data that has relation to another table


The idea is to store data in a table that has a relationship column (look up). I have two tables: Tools and Tool Tests. It is a one-to-many relationship - a Tool can have many Tool Tests. So, in the Tool Tests table there is a column for Tool. Whenever I create a Tool Tests record, I want that record to be related to a Tool. To my understanding, a value in the Tool column of the Tool Tests table should be entered that exists as a primary key in the Tools table.

The following code is what I am using. varTestData is data the I get after an API call and then have to iterate it with ForAll to go through all records. But I get and error on the line 'Tool': varSerialNo,. The error is:

Incompatible type. The 'Tool' column in the data source you're updating expects a 'DataEntity' type and you're using a 'Text' type.

I understand that the types are not correct, but I am unable to find anything on DataEntity. Is my approach incorrect at all or am I missing something in how I am assigning the value in the Collect function?

ForAll(
varTestData,
Collect(
    'Tallman Equipment Tool Tests',
        {
        'Torque Tool Model No.': 'Torque Tool Model No.',
        'Torque Tool Serial No.': 'Torque Tool Serial No.',
        'Beam Model No.': 'Beam Model No.',
        'Impacts Per Minute': Value('Impacts per Minute'),
        'Tool': varSerialNo,
        'Measurement Units': 'Measurement Units',
        'Peak Torque': 'Peak Torque',
        'Sample No.': Value('Sample No.'),
        'Test Duration': 'Test Duration',
        'Test Date': DateValue(Date),
        Time: Time,
        Torque: Value(Torque)
        }
    )
);

Solution

  • https://powerusers.microsoft.com/t5/Microsoft-Dataverse/DataEntity-Type/td-p/151948

    It’s something that’s going on for yours. relationships are for Model-Driven apps. In canvas apps, it’s horrible and won’t work as expected.