So I've made an app for our small library. I want to add a button to the detail screen for a quick checkout. Right now users have to use the edit screen to add in their name and it'll mark the book as unavailable. However, I'd love to have a button specifically for checking out and/or returning a book. When they hit the button I want it to take their username and fill in the "Checked out By" field for them. Then vice versa. I thought the patch function would be all I needed.
Patch(IPC_LIB, ThisItem.'Checked Out By', User())
I'm probably just using the wrong syntax I assume. Any suggestions?
Solved! Go to Solution.
So all of this works really well and I don't want to be a stickler, but here I go. I still find myself having to use the refresh button before anything will change immidiately. I don't know if there really is a way around it or not, however the button works both ways and so does the "Available?" field.
A lot of progress so thank you for your help.
So from the detail screen I hit the edit button.
and this is where I end up. Now I'll hit the button and show you what happens after.
So, I added the refresh button to the detail screen. After I hit refresh on this scree, this is what I get.
Which is exactly what I want, but obviously I'd love for it to update on its own without hitting the refresh button. I'm worried it might confuse our users.
So one of the things that I was kind of leaning toward before was...why even have an EditForm? There is nothing there to edit for the person checking out or in the book.
I was thinking more in terms of just having a screen with the Title and Author on it and a "Check out" or "Return" button (depending on the status). Which actually leads us back to either a Patch statement (because we have no need for a Form) or having the EditForm fields be read-only.
Also, was considering, would you be wanting some logic for the Return/Check-in? Seems you would want to check that the current user is the one that checked it out and only allow them to check it back in. For all others there would not be any option to do anything.
Just kind of thinking through your scenario, but not sure that it actually would be what you want.
As for the refresh button...no...you don't want that, nor would you need it - people will be confused. This is all quite possible to do without it.
Yes, I agree there's no real point to an edit form screen while having those buttons. The only thing I wonder is will the patch formula update the screen quick enough? And yes some logic to check the user would be wonderful.
Yes, if you are patching/updating a datasource, this is immediate as, behind the scenes, it is updating the local "collection" which is the datasource and then making the round-trip to the actual data source for the real update. The only "delay" would be experienced between multiple users on multiple devices. A single user on a single device should always see immediate change.
So based on some of this, I'd say that something like this would be better for your situation:
Label 1 - Let's call it lblTitle
Text property set to : BrowseGallery1.Selected.Title
Label 2 - Let's call it lblAuthor
Text property set to : BrowseGallery1.Selected.Author (assuming that's the column name for this)
Label 3 - Let's call it lblCheckedOutTo
Text property set to : BrowseGallery1.Selected.'Checked Out By'
Visible property set to : !(IsBlank(BrowseGallery1.Selected.'Checked Out By'))
Button 1 - Let's call it btnCheckInOut
Text property set to : If(IsBlank(BrowseGallery1.Selected.'Checkd Out By'), "Check Out", "Return")
Visible property set to :
IsBlank(BrowseGallery1.Selected.'Checked Out By') ||
(!IsBlank(BrowseGallery1.Selected.'Checked Out By') &&
BrowseGallery1.Selected.'Checked Out By' = User().FullName)
OnSelect action set to :
'Checked Out By': If(IsBlank(BrowseGallery1.Selected.'Checked Out By'), User().FullName, "")
Back() // If you want to then return to the calling screen
This will give you three static labels with the Title and Author and the person it is checked out to. The Check out to label will only be visible if it is actually checked out.
The button will only be visible if the book is not checked out to anyone (and will say "Check out") OR if the book is checked out to the current user (and it will say "Return").
When the button is clicked, it will patch the record from the BrowseGallery1. If the book is checked out, it will "blank" the column, if it is not checked out, it will fill in the current user. Remember, this button is only visible given the above conditions, so we don't have to do any further checking in this formula.
See if that concept and scenario works for you.
I apologize for this ignorant question, but should I be using these formulas on my browse screen or details screen? I tried setting them for my browse screen, but then no data appeared. I'll promptly try this on my details screen.
I would just create a new screen for it. There is no need for any other controls on it (except maybe some navigation header controls)
Check out new user group experience and if you are a leader please create your group
We are excited to announce that Demo Extravaganza for 2021 has started!
On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks
Don't miss the call this month on June 16th - 8a PDT