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.
IF all the changes are saved on sharepoint side (verify it) and the controls are not updating to those values you probably need to check the default of every single control in the form because if it is resetting it should be resettign to whatever their defaults are (and if its not their values in sharepoint then the form is probably set up wrong)
the changes are saved though. and then it just resets the fields.
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
@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..
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
@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.
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
@TheRobRush thanks but whats weird is I am getting another error
Name isnt Valid. Default isnt recognized.
*updated above with an example that is working on my side
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.
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