Set A Default Value Of The Look Up Column In PowerApps New Form

Overview

 
Using the text value of the one data source, we need to set the Look Up value of another data source. So, at that time, there is a possibility that we don’t have an ID column associated with the Look Up. We only have the value for the “Value” column, and we need to find its ID and store the data into the SharePoint list. At this time, we can go with the approach provided in this article.
 

Scenario

 
I have two data sources.
  1. SQL Server
  2. SharePoint
I have a column named “Designation” in SQL Server.
 
Now, in SharePoint, I have two lists.
 

Interview


Set A Default Value Of The Look Up Column In PowerApps New Form
 

Designation


Set A Default Value Of The Look Up Column In PowerApps New Form
 
In the list “Interview”, I have “Designation” as a Look Up column of Designation list.
 
When a user clicks on the New Form, the default Look Up value for the Designation field should be set automatically.
 
So, let’s get started!
 
Step 1
 
Create a new PowerApps Form.
 
We have a Designation column there.
 
Set A Default Value Of The Look Up Column In PowerApps New Form
 
Step 2
 
Select the Designation Data Card.
 
Add the Default Property as shown in the below screenshot or the code snippet.
  1. {  
  2.    '@odata.type' : "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",  
  3.    Id: LookUp(Designation_3,Title = "Software Developer",ID),  
  4.    Value: "Software Developer"  
  5. }  
Set A Default Value Of The Look Up Column In PowerApps New Form
 
Now, let’s understand its logic first!
 
Look Up column accepts the value in the Record format.
 
Now, let’s say below are my possible values for the Look Up drop down.
 
Set A Default Value Of The Look Up Column In PowerApps New Form
 
We only have a value in the text format that I want to set the default value as “Software Developer” in the dropdown. Then, how does Look Up column know what my ID is?
 
In order to find out the ID for the associated Look Up value, we will use LookUp function.
 
Below is the syntax for it.
 
Set A Default Value Of The Look Up Column In PowerApps New Form
Source = My SharePoint’s Designation List
Condition = Designation list > column name on which we need to apply the condition.
Result = Designation List > Result column name which we want
The above function will return us an ID associated with the text value.
 
Now, we have both the values available to set as the default value.
 
Step 3
 
We set “Software Developer” as Default Value.
 
Step 4
 
Run the form and fill the information.
 
Set A Default Value Of The Look Up Column In PowerApps New Form
 
Step 5
 
Check the result in the SharePoint list.
 
We can have “Software Developer” as a default value.
 
Set A Default Value Of The Look Up Column In PowerApps New Form
 

Conclusion

 
This is how we can easily set the Default Look Up column value in the PowerApps Form.
 
Hope you love this article!
 
Don’t forget to follow me!!
 
Happy PowerApping!!


Similar Articles