Switching to a table with unlimited rows is the right way to go. It's more flexible this way and you have longterm data you could use to analyze which assets are being used more/less frequently/how long.
When Patching a record back to the datasource, I assume you want both of these to occur:
- Check in the device if it has not been checked in yet
- Check out the device to the next person
You'll need some conditions around your Patch formula:
If(!IsEmpty(Filter(TransactionsList,AssetTag=AssetOut.Text && CheckedOutTo=StudentIDOut.Text && InOutStatus="Out")),
Patch(TransactionsList,First(Filter(TransactionsList,AssetTag=AssetOut.Text && InOutStatus="Out")),
{CheckedInBy: ,
CheckInDate: Today(),
CheckInTime: Now(),
InOutStatus: "In"
}
)
);
Patch(TransactionsList,Defaults(TransactionsList),
{AssetTag: AssetOut.Text,
CheckedOutTo: StudentIDOut.Text,
CheckOutDate: Today(),
CheckOutTime: Now(),
InOutStatus: "Out"
}
)
This means, "If there exists a record for the given Asset that is still checked out, then take the first matching record and update it to check it in. Regardless, write a new record to check it out."
If you want to prevent an asset from being checked out until it is formally checked in, you can set the Disable property of a Button to:
!IsEmpty(Filter(TransactionsList,AssetTag=AssetOut.Text && InOutStatus="Out"))
This means, "Disable this button when the given asset has a record which shows it is currently checked out."
Finally, before you make the switch to a datasource whose purpose is to gather unlimited records, I must caution you that Excel has a 500 record limitation. You will be able to write more than 500 records, but only the first 500 will ever be read by PowerApps in its current form. If you need a more robust datasource, I recommend the Common Data Service.