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 error, Name isnt...
Power Apps
Unanswered

Patch error, Name isnt Valid. ThisItem is not recognized.

(0) ShareShare
ReportReport
Posted on by 920 Super User 2024 Season 1

Hi,

 

I am trying to patch to update a value in my form. 

When i use - Patch('Data Source', ThisItem, {'impact comment':TextInput1.Text}) 

 

my formula gets the error "Name isnt Valid. ThisItem is not recognized."

 

why is this? I want to update the current record Im in.

 

Thanks.

Categories:
I have the same question (0)
  • TheRobRush Profile Picture
    11,128 Moderator on at

    try this

    Patch('Data Source', {ID: ThisItem.ID, 'impact comment':TextInput1.Text}) 
  • wonka1234 Profile Picture
    920 Super User 2024 Season 1 on at

    @TheRobRush  getting an error now 

    the type of argument 'ID' does not match the expected type 'Number' . Found type 'Error'
  • TheRobRush Profile Picture
    11,128 Moderator on at

    Sorry, that code would be for a gallery, when it's on a form you need to make it

     

     

    Patch('Data Source', {ID: Value(Parent.Default), 'impact comment':TextInput1.Text}) 
    
    
    example
    
    Patch(ParkingRequests, {ID: Value(Parent.Default),AssignedBarcode:12345})

     

     

    AND have the button doing this patch in a datacard set up for the items id.

     

    TheRobRush_0-1694454612495.png

     

    Or make parent.id First(datasource).ID or whatever the filter is to select this specific item (in the Item Property of the form) followed by .ID

  • TheRobRush Profile Picture
    11,128 Moderator on at

    *updated above with an example that is working on my side

  • wonka1234 Profile Picture
    920 Super User 2024 Season 1 on at

    @TheRobRush  thanks but whats weird is I am getting another error 

    Name isnt Valid. Default isnt recognized.
  • TheRobRush Profile Picture
    11,128 Moderator on at

    Any control you place into a datacard on a form should have access to Parent.Default. You may need to share pictures of your form, its source & item properties, the button and its datacard etc so we can see what you have got wrong there

  • wonka1234 Profile Picture
    920 Super User 2024 Season 1 on at

    @TheRobRush  what seems to work is this - I set gblRecordID before getting to this screen.

     

    Patch('Data Source', {ID: gblRecordID, 'impact comment':TextInput1.Text}) ;

     

    But now when i submit - it resets a field in my editform.

     

    This is DataCardVlaue40... And it is a dropdown.. When the dropdown is set to "New" then the popup comes up with the submit button, which contains the patch... Its like when I patch it resets DataCardValue40.

     

     

  • TheRobRush Profile Picture
    11,128 Moderator on at

    what is the dropdown based on default wise? If it is not based on the underlying data and is just an added control to the form that the user manipulates I'd say odds are when you patch the data, it updates the data in your app too, which resets the form because the item being displayed in the form has now changed. you would need to do something like when form loads set a variable for example Set(isNewVar, false) and make dropdown default check to see if isNewVar=false and if it does make your default whatever you want it ot be for a fresh form, and onchange of that dropdown if Dropdown.Selected.Value = "New" then Set(isNewVar, true) this way that dropdown will continue to show New until you "Load a new item" and thus trigger the Set(isNewVar, false)  again

  • wonka1234 Profile Picture
    920 Super User 2024 Season 1 on at

    @TheRobRush  Datacard dropdown default is blank... not sure how that happened as I believe it should be Parent.Default right?

     

    the datacard default is "thisItem.'Final Conclusion" 

     

     

    Anyway so I added Parent.Default to the dropdown datacardvalue and retried -

     

    Patch('Data Source', {ID: gblRecordID, 'impact comment':TextInput1.Text});. 

     

    Still refreshing datacardvalue to no choice. Realizing its refrshing other changes i make to.. wonder why..

  • TheRobRush Profile Picture
    11,128 Moderator on at

    because if you dont save any changes you made (via the patch) when you patch the item the item is now new and thus reloads your form to the new version of the record and a new form resets all the controls in the form

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 739 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 268

Last 30 days Overall leaderboard