I have the following:
Gallery with Add button (+)
Edit Form with the following buttons:
Delete (name is IconDelete1_1 on EditScreen1)
On the Gallery, when I click the Add button to add a new record, how can I disable the Delete button on the Edit Form ?
This is of course to prevent the user from attempting to Delete a non-existent record (SQL Server back end). From what I can tell, you need to use UpdateContext() and so on.I've tried multiple different syntax's and so on, but to no avail.
Solved! Go to Solution.
I assume that your Add button will invoke a NewForm(<FormName>)?
Then you should use the formmode of your Edit Form.
Just disable the delete button when Form.Mode = FormMode.New, If you edit an existing record the mode will be Edit and when vieweing a record the mode will be View.
"I assume that your Add button will invoke a NewForm()?"
Then you should use the formmode of your Edit Form."
"Just disable the delete button when Form.Mode = FormMode.New,"
Sooo ... how do I do that ? What is the code/syntax to actuallyDisable the DELETE button ... and where would I put it?
Is there an event when the Edit Form opens ? thx
OK ... that works. Thank you.
This is what was in the Delete button DisplayMode property:
If(!IsBlank(BrowseGallery1.Selected) && DataSourceInfo('[NEM].[ztblNEM2Enh]', DataSourceInfo.DeletePermission), DisplayMode.Edit, DisplayMode.Disabled)
where [NEM].[ztblNEM2Enh] is a table in my SQL Server back end.
It would seem that code (generated when I let PA create the app) should Disable the button, but it's not. I think that is because there is always an item 'selected' in the BrowseGallery1.
I tried just If(!IsBlank(BrowseGallery1.Selected), DisplayMode.Edit, DisplayMode.Disabled) ... that does not work either.
Why do you suppose that is ?
Nonetheless ... I'm using the code you provided. I'm not really concerned with 'DeletePermission' in this app.
Appreciate the help.
Funny ... I've been working 24x7x365 with Microsoft Access / VBA for 25 years. Things like this are second nature. BUT ... the syntax in PA is quite different. BOOM !
Learn how to create your own user groups today!
Check out the new Power Platform Community Connections gallery!
Congratulations, the new Super User Season 2 for 2021 has started!
Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.