cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
trandallvermont
Frequent Visitor

Set Lookup Field Value based on button pressed

Hi, 

 

We are creating a Power App that takes information from a SharePoint list (the Inventory List) and populates another SharePoint list (the Change Log). Here is a rough outline of the process:

 

trandallvermont_0-1651073342038.png

 

The Power App is essentially a SharePoint form for the Change Log. We have updated the default values for this form to populate with the appropriate values from the Inventory List. Here is the form:

 

trandallvermont_2-1651073427679.png

 

 

In certain cases, we require updates because information is missing in the inventory. To accommodate this, a Param is encoded in the link in the initial email that sets the noRequiredUpdate variable to true or false.  In turn, that true or false value is applied to the Visible property on the No Changes Needed group (red button) to hide it

 

For reference, here is the OnStart statement used to pull in that Param and set the variable:

Set(noRequiredUpdate,Value(Param("noRequiredUpdate")))

 

What I am trying to do, is set the Change Status value based on the button that is selected with the hope to hide the field on the form. If the Submit Changes value is clicked, I want the Change Status value to be "Submitted"; whereas if they select No Changes Needed, the Change Status value should be set to "No Changes Submitted".

 

I have tried setting a variable ChangeStatusVari for the buttons' OnSelect properties:

Set(ChangeStatusVari,"Submitted")

 

However, I can't seem to get the lookup statement correct for the DataCardValue5 to work:

trandallvermont_4-1651075047489.png

 

Here is my Default property that I am setting:

LookUp('SharePoint Sites & Teams Change Log'.'Change Status','Change Status'.Value=ChangeStatusVari,ThisRecord)

 

I have confirmed that my ChangeStatusVari variable is being set:

trandallvermont_5-1651075148051.png

 

Does anyone have any suggestions on what the Lookup formula should be on my Default property for this DataCard?

 

Thanks in advance, 

Thomas

1 REPLY 1
Silvester
Super User
Super User

First, you do not need the "ChangeStatus" to be a  dropdown. It could be just a label or a text field, because you dont require the user to make changes to it, it is a behavioral field.
On your "SubmitChanges" button, add 

Patch(Datasource,Record,{ChangeStatus:"Submitted"})

And for your "No changes Needed",add

Patch(Datasource,Record,{ChangeStatus:"No changes Submitted"})

Do let me know, if you want to go with the drop down so i show you what to do, I do find the proposed solution to be easier and less tedious
If you find this post interesting, give it a thumbs up, you can also accept it as a solution to allow other to find it.

Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the thread and so other members of the community can find it easily.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (6,264)