cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bs-dev001
Advocate I
Advocate I

Validation logic before a record is saved

We are building a simple model driven app to manage card keys.  The app aims to keep track of who used the card key and when it was returned.

 

The tables we have are:

- CardKey

- Transaction

 

The user creates a Transaction record and in its look-up field he selects a Card key record and save the record.  When the user returns the card key, he would select the return date time and save it.  Now we want to prevent other users from using the same card key that someone else currently uses.  If the user selects a card key that has already been in someone else's hand, at the time of pressing "save" icon I want to display a warning message so that the user knows he needs to select other card.  I think I should implement some sort of validation logic before the record is saved in Dataverse to achieve the above case.  Looking at the "Business Rule", I don't think it fits in this scenario.  Does anyone have ideas for it?

3 REPLIES 3
WarrenBelz
Super User
Super User

Hi @bs-dev001 ,

I assume the date is relevant as well? If so, on the Save button

If(
   !IsBlank(
      LookUp(
         CardKey,
         KeyNumberField = CardKeyDropdowen.Selected.xxxx &&
         DateField = Today()
      ).KeyNumberField
   ),
   Notify(
      "Card already allocated",
      Error,
   ),
   YourSaveCodeHere
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

If it is a Canvas app, then the formula you mentioned makes perfect sense but this is a model driven app due to the historical reason and relationship with other apps.  Embedding a Canvas app is not a way to go. @WarrenBelz 

Hi @bs-dev001 ,

I do not use these unfortunately, but was not aware that this simple formula was not relevant there. I will be mindful of this as I try to restrict the posts I answer to ones I believe I can assist on.

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Users online (2,671)