I am getting the "Expected a value compatible with 'DataSource'" error when trying to create an EditForm.
The Form's Item property is set to DataTable.Selected, and its DataSource property is the same as DataTable.
I think it might have something to do with the fact that I have a formula in the Item property for DataTable, but I am not sure how to resolve it.
The DataSource on the EditForm needs to be the data source that is being used in the Items property of the DataTable.
I have tried copying and pasting the Item property from the DataTable into the DataSource property of the EditForm, which clears the error, but creates another error with my Submit button.
The Submit button now gives the error "The data source supplied to the function is invalid". The function being SubmitForm(EditForm).
The form also displays the "This form isn't connected to any data" message in the background. It most definitely is connected to data.
What is the value in the DataSource of the EditForm?
Currently, the value for both DataSource in the EditForm and the Item property in the DataTable is -
SortByColumns(Filter(AddColumns('Electronic Diary',"FormattedDateandTime", Text('Date and Time', "[$-en-GB]dd/mm/yyyy, hh:mm")), SearchInput.Text in Title || SearchInput.Text in Details || SearchInput.Text in 'Ticket Number' || SearchInput.Text in FormattedDateandTime || SearchInput.Text in Equipment ),"DateandTime",Descending)
The data is manipulated before being displayed in the DataTable to change date format and use a search bar (one search bar for all columns).
I have tried setting the DataSource property in the EditForm to 'Electronic Diary' (The actual datasource of the table, prior to manipulation) but that is when I am presented with the compatible value error.
I believe the issue is that AddColumns creates temp collection and DataTable.Selected is a record on that temp collection. Is there a unique value on the selected record? If so you could change the Item property of the EditForm to Lookup('Electronic Diary', DataTable.Selected.UniqueFieldValue = UniqueFieldValue) which will give you the record in 'Electronic Diary'.
Thank you for your help so far @Jeff_Thorpe, I'm a lot closer now.
The lookup method you suggested -
Lookup('Electronic Diary', DataTable.Selected.UniqueFieldValue = UniqueFieldValue)
seems to return the wrong record.
Could this be because the temp collection is sorted by date, whereas the DataSource is unsorted? I can't really think of any other cause.
The sort shouldn't affect the lookup value being returned since the condition is based on a unique field value. If the value isn't unique then the lookup will return the first one it finds with that value (DataTable.Selected.UniqueFieldValue = UniqueFieldValue).