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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patch with variable
Power Apps
Answered

Patch with variable

(2) ShareShare
ReportReport
Posted on by 95
Hello,
 
I set a variable on OnCheck property of an item in a gallery:
 
Set(varShowPopup; true);; Set(varZatrhatko; Title11.Text)
 
Then it shows me a confirmation popup screen and I would like to Patch it, if Selected Yes:
 
Patch(DelnikVNKN;Defaults(DelnikVNKN);{Delnik:galDelnik.Selected;VNKN:varZatrhatko});; Set(varShowPopup_1; false)
 
What I am receiving are two failures:
*Some arguments of Patch arent valid.
*Type of this argument: "crf13_VNKN" isnt responding the expected type "Record". It was found "Text".
 
-variable loads just fine
-Patch without a variable (with no popup) works fine also
-tried also a collection instead of variable, no work
 
It has to be something easy, but I dont know now
Many thanks
Categories:
I have the same question (0)
  • ronaldwalcott Profile Picture
    3,847 Super User 2025 Season 2 on at
    What is the type of crf13_VNKN? The error message seems to indicate that it doesn't appear to be a text field. 
  • vipuljain03 Profile Picture
    665 Super User 2025 Season 2 on at
    It looks like the issue is with how varZatrhatko is used in the Patch function. VNKN is expecting a record, however varZatrhatko is a text value.
     
    It depends what VNKN column is expecting in your data source, it could be a text value or a record or its a lookup field (in this case you must pass an object with .Id or .Value) etc.
     
    If it expects a record, then you have to pass the value in curly braces {}.
     
    E.g.:
    Patch(
        DelnikVNKN, 
        Defaults(DelnikVNKN), 
        {
            Delnik: galDelnik.Selected,
            VNKN: { Id: LookUp(VNKNSource, Title = varZatrhatko).ID } // Pass ID explicitly
        }
    );
    Set(varShowPopup_1, false)
     
     
  • DavidZoon Profile Picture
    738 Most Valuable Professional on at
    Hello,
     
    Your VNKN field is probably a lookup or a choice field, you can't populate this field with a text value, you variable varZatrhatko should respect the expected format of your VNKN column
     
  • JM-14081323-0 Profile Picture
    95 on at
    Thanks vipuljain03
     
    it is indeed a lookup column. It is a column in a joint table DelnikVNKN that looks into table VNKN, column Seznam.
     
     
    I wrote this:
    Patch(DelnikVNKN;Defaults(DelnikVNKN);{Delnik:galDelnik.Selected;VNKN: {Id: LookUp(VNKN;Seznam = varZatrhatko).ID}});; Set(varShowPopup_1; false)
     
    and got four errors:
    *Identificator ID not recognized
    *Some arguments of function Patch arent valid.
    *Invalid type of argument. Expected value of type Record, but different scheme.
    *Missing column. In formula there isnt column "Owner" with type "Polymorphic"
     
    I dont quite understand where the identificator Id comes from.
    Thank you for explaining
    Jirka
  • Suggested answer
    vipuljain03 Profile Picture
    665 Super User 2025 Season 2 on at
    Can you please try below code:
    Patch(
        DelnikVNKN, 
        Defaults(DelnikVNKN), 
        {
            Delnik: galDelnik.Selected,
            VNKN: LookUp(VNKNSource, Title = varZatrhatko) // Ensure you fetch the correct record
        }
    );
    Set(varShowPopup_1, false)
    📌 VNKNSource should be the actual data source where VNKN exists.
  • Verified answer
    JM-14081323-0 Profile Picture
    95 on at
    Thank you very much amigo!
     
    I solved it yesterday with collection and first function. That works on OnCheck/OnUncheck property:
     
    Patch(DelnikVNKN;Defaults(DelnikVNKN);{Delnik:galDelnik.Selected;VNKN: First(colZatrhatko)});; Set(varShowPopup; false)
    Remove(DelnikVNKN;LookUp(DelnikVNKN;Delnik.Jméno = galDelnik.Selected.Jméno && VNKN.Seznam = First(colZatrhatko).Seznam));; Set(varShowPopup_1; false)
     
    However your proposal now works for me as well with minor improvement:
     
    Patch(DelnikVNKN;Defaults(DelnikVNKN);{Delnik:galDelnik.Selected;VNKN: LookUp(VNKN; Seznam = Text(varZatrhatko))});; Set(varShowPopup; false)
    Remove(DelnikVNKN;LookUp(DelnikVNKN;Delnik.Jméno = galDelnik.Selected.Jméno && VNKN.Seznam = Text(varZatrhatko)));; Set(varShowPopup_1; false)
     
    Now I swapped collection for a variable, because it makes more sense to me ;)
  • Suggested answer
    vipuljain03 Profile Picture
    665 Super User 2025 Season 2 on at
    Please mark my solution as Verified Answer, so that this thread can be closed.
     
    Thanks in advance.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard