cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
akosila
Helper I
Helper I

Assign patch to a variable

I have this reusable patch, and I don't want to put this patch in all of the buttons that I have.

 

I tried to do this in OnVisible of the screen

 

Set(varPatchInfo,  Patch(
            'SP-List-Data',
            LookUp(
                'SP-List-Data',
                'RefID' = txtRefID.Text
            ),
            {
                
                    'RefID': txtRefID.Text
                    ,'Number': txtNumber.Text
             }))

 

  

And in the OnSelect of my button, I call the variable varPatchInfo

 

but it doesn't work

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @akosila , 

I see what you want now, but you simply cannot “automate” or “store” an action in a Variable. You can however use the Select() statement to run the code from all buttons by using

Select(YourFirstButtonName)

and simply putting the Patch code on that button.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

4 REPLIES 4
WarrenBelz
Super User III
Super User III

HI @akosila ,

I am not sure exactly what you are trying to do here, but you are Patching your list every time and setting the number (not a good name for a field - it is a Reserved Word in Power Apps - you might read this blog of mine) field to the value of a control and then setting a Variable to this value. The below is a shorter version of the same code.

Set(
   varPatchInfo,  
   Patch(
      'SP-List-Data',
      {'RefID': txtRefID.Text},
      {'Number': txtNumber.Text}
   )
)

 If you simply want to set a Variable to the record where RefID equals txtRefID.Text in the List 'SP_List_Data', then do this

Set(
   varPatchInfo,  
   LookUp(
      'SP-List-Data',
      'RefID'=txtRefID.Text
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Hi @akosila ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Hi sorry, I am out for the past weeks.

 

What I want to do is to assign that whole patch statement so  I can just call the variable in my button.

(FYI, the 'Number' is a typo, it should be 'txtNumber')

Anyway, I have several "Save" buttons, and basically, they just need to patch the same thing, my worry is that when I need to update the patch statement, I need to modify ALL the buttons. 


But if I resolve this, I just need to modify my variable and all the button follows since they have that as their OnSelect.

 

Hi @akosila , 

I see what you want now, but you simply cannot “automate” or “store” an action in a Variable. You can however use the Select() statement to run the code from all buttons by using

Select(YourFirstButtonName)

and simply putting the Patch code on that button.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

Top Solution Authors
Top Kudoed Authors
Users online (85,895)