Hello. I'm facing an issue with setting the default value of a Lookup column. My datasource is a SharePoint list. I have a parent/child relationship between two lists. For example, I have a "Projects" list and another "Time" list with a lookup column pointing to the Projects lists so you can put time in for a particular project. On my New Form for the Time List in PowerApps I want to auto-populate the Project Lookup column with the currently selected Project that I have as a global variable in PowerApps. I thought I could do this by setting the Default Value of the Lookup Data Card to this:
{
'@odata.type' : "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Id: varWO,
Value: varWO
}
It looks like in the Preview it is setting the value correctly, however, when I submit no record is added to the list and I see an error that "A value must be provided for item".
Has anyone else ran into this? Is this a bug? This project needs to be done by Friday morning and this is the last thing I have to do to get it done and I'm out of ideas. I even tried just creating a single line of text field and trying to auto-populate that with my global variable. That will create a record but with a blank column value.
The record you are passing in the default formula is expecting a number for "ID" and string for "Value". You are using the same variable for both "ID" and "Value" because your lookup item ID is also the same as your Title field and I believe this is what is causing your issue. I am assuming your variable is storing the value as a string, so when you use it for "ID" it isn't a valid data type. Try wrapping the Value function around the variable when it is used with "ID" to convert it to a number.
Here is an example.
{ '@odata.type' : "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference", Id: Value(varWO), Value: varWO }
Hello. I am using the exact configuration you mentioned in the default value of the lookup. In my SharePoint List the ID and Title are the same value. I have a global variable in my PowerApp that is getting the ID for the lookup and I'm passing that in the default value logic. I've verified that the value in my global variable matches the ID and Title of the lookup item in question. Despite this, I still get the error when submitted.
Hi @aprildunnam,
What is your current situation?
The default value of the lookup should be configured as below:
{ '@odata.type' : "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference", Id: 'The corresponding Item ID of the Lookup list item', Value: 'The value of the Lookup list item' }
I suspect the reminder should mention that the Id value is not within the available data range.
Basically, Id field should be the corresponding Item ID of the value you would like to set, and the value property should be set to the data of the lookup field.
The data would be saved successfully only when the Id and the Value matches to the same item of the lookup list item.
Regards,
Michael
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.