I am now trying to create the equivalent functionality in an App embedded in PowerBi
The faster UpdateIf and Patch approach does not work in an App embedded in PowerBI so I have reverted back to ForAll and Patch approach. The below works to Edit existing records
ForAll(
Collection,
Patch(
DataSource,
LookUp(
DataSource,
crb8f_datasourceid = Collection[@crb8f_collectionid]),
{
DataSourceField1: DropDownLookUpofDataSourceField1.Selected,
DataSourceField2: DropDownChoiceofDataSourceField2.Selected.Value,
etc etc etc,
}
)
)
However when it comes to copying existing records, the equivalent Patch does not work, I think because of the difference between the patch expecting a Record and I am giving it a Table from the dropdown (something like that, I may have it the wrong way round!)
ForAll(
Collection,
Patch(
DataSource,
Defaults(DataSource),
{
DataSourceField1: DropDownLookUpofDataSourceField1.Selected,
DataSourceField2: DropDownChoiceofDataSourceField2.Selected.Value,
etc etc etc,
}
)
)
);
I got round this by trying.......
Patch(collection,
Defaults(sourcetable),
{ SourceField: LookUp(sourcetable, sourcefield in [@Collection].crb8f_CollectionField) }));
If the collection contains 4 records, all with different field content, the Patch will create 4 records, however all 4 records are crreated exactly the same, but the fields are populated based on the first record Power Apps finds in the Collection table (I guess because I am using the Lookup function) This is the best way I can explain, it.
Collection Records
Record 1: FieldA: 1a FieldB: 1b FieldC: 1c FieldD: Field updated by user in Power Apps
Record 2: FieldA: 2a FieldB: 2b FieldC: 2c FieldD: Field updated by user in Power Apps
Record 3: FieldA: 3a FieldB: 3b FieldC: 3c FieldD: Field updated by user in Power Apps
Record 4: FieldA: 4a FieldB: 4b FieldC: 4c FieldD: Field updated by user in Power Apps
New Records Required
Record 5: FieldA: 1a FieldB: 1b FieldC: 1c FieldD: Field updated by user in Power Apps
Record 6: FieldA: 2a FieldB: 2b FieldC: 2c FieldD: Field updated by user in Power Apps
Record 7: FieldA: 3a FieldB: 3b FieldC: 3c FieldD: Field updated by user in Power Apps
Record 8: FieldA: 4a FieldB: 4b FieldC: 4c FieldD: Field updated by user in Power Apps
New Records Created
Record 5: FieldA: 1a FieldB: 1b FieldC: 1c FieldD: User defined field
Record 6: FieldA: 1a FieldB: 1b FieldC: 1c FieldD: User defined field
Record 7: FieldA: 1a FieldB: 1b FieldC: 1c FieldD: User defined field
Record 8: FieldA: 1a FieldB: 1b FieldC: 1c FieldD: User defined field
Do I need to change when I trigger the ForAll loop or something?