I'm working on an app where I'd like to get a blank record whose columns are based on a SharePoint list.
ClearCollect(myCollection, First(Filter(myList, ID=-1)))
Both of these techniques return the columns, but there technically isn't a record... it's an empty list. I want -ONE- single record that contains the columns and whose records are all nulled/blank.
The only other technique I can think of is:
ClearCollect(myCollection, Filter(myList, ID=[existing ID]));
This seems really involved, especially since my list has over 2-3 dozen columns. Is there an easier way to do this?
I want to mention that my emphasis for this question is on method, not syntax (in case I messed up my syntax for whatever reason).
Hi @tommyly ,
Do you want to get the Blank record from a SP List?
Based on the formula you provided, I think there is something wrong with it. Actually, you should not save the filtered result into a collection within your app.
Currently, within PowerApps, the collection would be acted as a Table value rather than record value. Even though, you save a Blank record into the collection, the collection would be acted as empty table rather than Blank record.
As an alternative solution, I think global variable could achieve your needs. You could consider save the filtered result into a variable. Please consider take a try with the following formula:
Set(BlankRecord, LookUp(myList, ID = -1))
Then you could reference the column value through the following formula:
You could review the Blank record data structure using Data Table as below:
Actually, the result the LookUp(myList, ID = -1) formula returned is just a Blank record. It is not necessary to save the the result into a collection, you could use it directly within your app.
If you just want to save the Blank record into a collection, and want the Blank record to be be acted as below:
I think the Defaults() function could achieve your needs. Please consider modify your formula as below:
Please consider take a try with above solution, check if the issue is solved.
When I purposely filter for a non-existent ID (whether Blank() or -1), it returns an empty table--which is not my goal. My intention here is to create a real, tangible record (in contrast to a table with multiple records or a table with no records) with blank values within each field. The result would be a blank, editable record of sorts--which I'll arbitrarily call a "Blank Record" (not an empty table).
The ultimate goal is this: Fields on the app have their default setting dynamically set to:
If(IsBlank(blankRecord.fieldA), copyOfDataSourceRecord.fieldA, blankRecord.fieldA)
When the user refreshes the data, this occurs:
ClearCollect(copyOfDataSourceRecord, First(Filter(DataSource, ID=X)))
That way, while offline, user input is recorded in the blankRecord collection. If the user refreshes the data, it will only refresh the fields that the user has not updated yet (because they'd be blank). The fields where the user has updated, the user's changes supersede what has updated on the data source.
I thought more about this and I know that you can create a sort-of-blank record using Defaults(dataSource), but I don't think this works the same way with collections--e.g. Defaults(collection)--as collections don't seem to inherit default values and meta-information of that sort.
Did you try the suggestion above of:
If myList is your actual data source, then presumably you'd get the defaults from there added as a new row to your collection.
Read the announcement for more information!
Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.
Features releasing from October 2019 through March 2020
Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications