web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / patching the varaible ...
Power Apps
Answered

patching the varaible with lookup

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

hi expert

is there a way to set a variable and patch the SP list with lookup

for example 

i want to set variable to the below code: 

Patch(
Forecast,
LookUp(Forecast, UniqueID=Value(DataCardValue174.Text)),

{
ApprovalStatus: "Approved",

})

 

desired code: 

Set(varRecord,Patch(Forecast,varRecord,

LookUp(Forecast, UniqueID=Value(DataCardValue174.Text)),

{
ApprovalStatus: "Approved",

ActiveStatus: {Value: "Active"}))

 

but i am getiing error in this 



Categories:
I have the same question (0)
  • Verified answer
    BCBuizer Profile Picture
    22,831 Super User 2026 Season 1 on at

    Hi @Anonymous ,

     

    Removed varRecord from the Patch statement and added a closing curly bracket:

    Set(varRecord,
    	Patch(
    		Forecast,
    		LookUp(
    			Forecast, 
    			UniqueID=Value(DataCardValue174.Text)
    		),
    		{
    		ApprovalStatus: "Approved",
    		ActiveStatus: {Value: "Active"}
    		}
    	)
    )

     

     

     

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    If you already have the record and the primary key...why look it up again??

    Please consider changing your Formula to the following:

    Set(varRecord,
     Patch(Forecast,
     {UniqueID=Coalesce(varRecord.UniqueID, Value(DataCardValue174.Text)),
     ApprovalStatus: "Approved",
     ActiveStatus: {Value: "Active"}
     )
     )
    )

    The above assumes that UniqueID is your primary key.  If not, then change as needed.

     

    I hope this is helpful for you.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    Just keep in mind with that formula you chose - that you are hitting your datasource twice.  So, if performance is not a concern, then use it.  Otherwise consider using the value that you have already gone to the datasource for before.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    i tried using that but its giving an error and yes unique id is primary key 

     

    pokhani_0-1661874549834.png

     

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    Then you appear to be using Dataverse.  The error in this case is because the Coalesce is trying to coalesce between a value of the Text input and a record.

    That should be simply adjusted to account for the proper types.  Coalesce has to coalesce between the same types.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 483

#2
WarrenBelz Profile Picture

WarrenBelz 399 Most Valuable Professional

#3
11manish Profile Picture

11manish 327

Last 30 days Overall leaderboard