cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
JuP1
Level: Powered On

Sharepoint list, lookup and default value in a form

Hello,

 

I meet a little problem with default value in forms. 

 

The problem is very simple. I have a sharepoint list (A) which use another one (B) with a lookup column (and other things). 

 

In powerapps, I create a form with some fields and our combobox for the lookup column. I just would like use a default value for this last field. I tried lot of things but nothing works Smiley Frustrated. I get every time an error when I submit my form:

 

2018-01-23_10-33-10.png

 

The problem is of course my default value in my combobox control. If I delete it, everything works well Smiley Mad. My last test is that:

In default field in the datacard:

If(IsBlank(ThisItem.D_x00e9_monstration);First(Filter(Demonstration;ID = EditForm1.LastSubmit.ID));ThisItem.D_x00e9_monstration)

 

D_x00e9_monstration: Column in my sharepoint list "A"

Demonstration: Sharepoint list "B"

First(Filter(Demonstration;ID = EditForm1.LastSubmit.ID)): the good record from "B", this is my default value for the combobox control.

 

Any Idea?

Thanks in advance Smiley Happy

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Sharepoint list, lookup and default value in a form

Here is a way you can code the default value into Combo box. The formula goes into the Default property of the DataCard. The "If" condition is there so that it only sets the default value if it is a new item.

 

If(EditForm1.Mode = New, {
'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
	Id: 3,
	Value:"Blue"}, 
ThisItem.D_x00e9_monstration)

Id = should the the Id number of the item in your Demonstration lookup list that you want to be the default.

Value = Should be the value of the item in your Demonstration lookup list that you want to show as the default value.



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly.
If you thought this post was helpful, please give it a Thumbs Up.
3 REPLIES 3
Super User
Super User

Re: Sharepoint list, lookup and default value in a form

Here is a way you can code the default value into Combo box. The formula goes into the Default property of the DataCard. The "If" condition is there so that it only sets the default value if it is a new item.

 

If(EditForm1.Mode = New, {
'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
	Id: 3,
	Value:"Blue"}, 
ThisItem.D_x00e9_monstration)

Id = should the the Id number of the item in your Demonstration lookup list that you want to be the default.

Value = Should be the value of the item in your Demonstration lookup list that you want to show as the default value.



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly.
If you thought this post was helpful, please give it a Thumbs Up.
JuP1
Level: Powered On

Re: Sharepoint list, lookup and default value in a form

Hi!

 

Thank you very much Jeff, it works perfectly ! 

smsdavis
Level: Powered On

Re: Sharepoint list, lookup and default value in a form

I'm trying to do something similar but I do not understand this explanation.  

 

If(SharePointForm1.Mode = New, {
'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
	Value:"Blue"}, 
ThisItem.FavoriteColor)

You then say to change "Blue" and the SharePointForm1.  Ok...My form is named SharePointForm1  no problems there.

 

But what I want for "Blue" is the actual VALUE from the previous screen's field.  Basically, I have an Order Sharepoint List and the user got to Power Apps by clicking Edit which (hopefully) will pull up the new Power App edit screen for the item.

 

The screen shows all the shipments associated with the order.  No problem.

 

There is a NEW button for the user to click to add a shipment which opens up the second screen.

 

This second screen has a Lookup field going back to the OrderId of the previous screen.  I have searched and searched and the only answers that come up is this same "Blue" example.  I do not have some static data I want defaulted.  I want a FIELD from that first screen.  How do you replace "Blue" with an actual FIELD VALUE from the previous screen?

 

HELP please....