Tracking number of times something is used

Hi, I am creating an app that checks items in and out. I want to track how often those items are checked out.

Let’s use the library example, so checking out books.

I have data for Libraries, Users, and Books. I want to track how many books the each library checked out each month, how many books each user checked out, and how often a particular book was checked out.

I am guessing I need a number data type to track this in in each one, so each one has a number section in the data.

I am confused about where to put this in the workflow. Should I create a custom API for it? There’s a moment in the workflow when the book is checked out, should I just “Make changes to” at that moment without the API? I guess I am just worried there is too much other stuff happening at that time and I don’t want the app to freeze while it loads.

Thanks!

I’ve tried calling it at that moment by using a Make changes to, but it didn’t work. I think it’s not pulling through the books that are checked out, I have a whole set up for it to be able to check out multiple books at once.

Hi there,

Have a field of type number on the thing. In your checkout workflow, add a step that adds +1 to that number’s value.

Alternatively, if you have a separate datatype called ‘Checkouts’, where you create a new Checkout each time something is taken out, with fields for Out and In dates, user, due date, the thing being checked out, etc, you can just run a Count on the amount of times this thing was Checked Out.

You could also do a combination of these 2 approaches: a simple number value in the thing that increments, and the separate checkouts.

2 Likes

Hi @msgiblin, thanks for your response!

These are great suggestions. The +1 to the value in your first suggestion is just hard because I am not sure how to connect the step to the right item. I had to do a workaround to make it so multiple items could be checked out at once, so I need to figure out where that’s stored again so I can make sure the +1 is going to the right place.

When you say “run a Count,” do you mean potentially making a separate page that shows all the items and then displays the counts of those items by searching through the Checkouts datatype? Just wondering where that info would live and the best way to get to it.

Thanks!

1 Like

As the user Checks Out the books, you could add a step ‘make changes to a list of things’, and set the list to change as the items in the cart. Value to change: each item’s Qty Value, +1.

If that’s where you need to display the counts, then yes on a separate page (like a dashboard), but if that is not something you need, you can still do a count on a datatype and display it anywhere (like next to each item in a search results, for example).

Although I would still recommend creating another datatype ‘Checkout-Item’, with fields for Book, Date Out, In Date, etc. And then a datatype of ‘Checkout’ which has the User, a list of Checkout-Items, Date Out, Date Closed (when all items are In), etc., as opposed to keeping most of this tied to the particular book.

1 Like

Hi @msgiblin, thanks so much! I officially figured it out!

What I was doing wrong was saving the list in the data type, and instead I used a Set State on the page itself which made it wayyyy easier to call the items and change them as needed.

I did create datatypes like “Checkout-Item” and “Item-Request,” and within those I had number value fields that I could add a number equal to a count of the items in my set state.

Thanks for your help!

1 Like

Happy to help and glad to hear you got it working!