@kriggo15
Column matching is highly important. Not only must you provide the proper names of the columns in your collection to match the datasource, but also you must make sure the values are as expected.
This is one of the complexities of working with collections instead of working direct with the datasource.
So you will need to either adjust your column names properly and also drop any columns from your collection that you added in order for it to work properly.
Ex:
Collect(yourDataSource,
ForAll(
DropColumns(Filter(yourCollection, IsBlank(ID)),
"ID", "addedColumn1", "addedColumn2", etc...
) As _item,
_item
)
);
Patch(yourDataSource,
DropColumns(
Filter(yourCollection, !IsBlank(ID)),
"addedColumn1", "addedColumn2", etc...
)
)
If you have different names on columns than the datasource, then you need to rename them.
Ex.
Collect(yourDataSource,
ForAll(
RenameColumns(
DropColumns(Filter(yourCollection, IsBlank(ID)),
"ID", "addedColumn1", "addedColumn2", etc...
),
"wrongNameColumn1", "ProperNameColumn1",
"wrongNameColumn2", "ProperNameColumn2"
) As _item,
_item
)
);
Patch(yourDataSource,
RenameColumns(
DropColumns(
Filter(yourCollection, !IsBlank(ID)),
"addedColumn1", "addedColumn2", etc...
),
"wrongNameColumn1", "ProperNameColumn1",
"wrongNameColumn2", "ProperNameColumn2"
)
)
If you don't go that route, then you will need to recreate your entire record schema in the ForAll
Ex:
Collect(yourDataSource,
ForAll(Filter(yourCollection, IsBlank(ID)) As _item,
{column1: _item.CollectionColumnName1,
column2: _item.CollectionColumnName2,
..etc..
}
)
);
Patch(yourDataSource,
ForAll(Filter(yourCollection, !IsBlank(ID)),
{primaryKeyColumn: _item.OrimaryKeyColumn,
column1: _item.CollectionColumnName1,
column2: _item.CollectionColumnName2,
..etc..
}
)
)
Depending on the amount of columns, it's a lot of work at times.
This is why your collections should be made from the datasource schema directly all the time, or skip the collections and work direct with the datasource.