30
Views
6
Comments
Solved
Validation to prevent user from inputting value more than available quantity
Application Type
Reactive

Greetings, I'm currently making a logic to prevent user from inputting Sales Quantity more than Available Quantity (Sales Quantity < Available Quantity),

but I think I missed something on my IF statement because it always goes for the FALSE statement which is "The amount of Sales Quantity that user inputted exceed the limit which is the Available Quantity" (Sales Quantity > Available Quantity)

for exp:
Sale Quantity = 100 and Available Quantity = 122  then -------> IF Statement -----> False Statement

What should i do to fix it (I already make the IF statement Sales Quantity < Available Quantity but still cant work) ? Sorry for my English

Thanks





Screenshot 2024-05-25 003557.png
Screenshot 2024-05-25 003655.png
Screenshot 2024-05-25 004416.png
2023-04-29 03-33-29
Omar Hussein
Solution

Hello Denise, 

You are trying to retrieve stock data from GeSalesByID aggregate, but since you are adding a new item there is no Id, thereby data is not retrieved for Stock.

To implement such validation, I would add another aggregate to the screen: GetAvailableStock with filter (Stock.Id = GetSaleById.List.Current.Sales.StockId --> selected stock type id by user), then inside the add action i would refresh the GetAvailableStock and check if requested quantity is more than or equal available quantity.
I have attached sample logic, I hope this will help you

Screenshot 2024-05-24 231929.png
StockQuantity.oml
UserImage.jpg
Denise Ady

Greetings Omar,
I added new aggregate GetAvailableStock from Stock Database ,set the filter as u suggested and modified the action....now it worked, Thanks ^--^

2021-03-18 21-03-15
Benjith Sam
 
MVP

Hi Denise, as mentioned in my previous response, one of the best way to learn and to identify the cause of such logical issues is to debug the implemented flow. If you're facing difficulties with how to use the debugger, it's worthwhile to invest time in going through these learning materials: https://learn.outsystems.com/training/journeys/debugging-639

If you still need assistance after attempting the debugging approach, sharing an isolated sample OML containing only the screen and logic for which you need help with the community can be beneficial.


Kind regards,

Benjith Sam

UserImage.jpg
Denise Ady

Greetings Benjith,

Thankyou for the suggestion about the debugging tutorial, it helps me a lot to trace the logic flow error ^--^

2019-01-07 16-04-16
Siya
 
MVP

A couple of observation worth implementing in your coding

  1. All validations should be performed before Form1.Valid . You can learn on this at https://learn.outsystems.com/training/journeys/form-validations-640
  2. There is an assignment CreatedBy which you are assigned on the client side. Move this to Server side before Creating records in Sales entity
  3. You must perform all the validations on the Server Side as well before you insert the data.


UserImage.jpg
Denise Ady

Greetings Siya,

I've done what you suggested to me which is making all validation performed above the Form1.valid and moving out "CreatedBy" assignment to Server Action. I also gonna try to perform the validation on server side. Thanks ^--^

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.