web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Check entered qty is l...
Power Apps
Answered

Check entered qty is less than stock available.

(0) ShareShare
ReportReport
Posted on by 68

I built a IT inventory app.

 

Validation in powerapps 

Switch(
DataCardValue26.Selected.Value,
"PURCHASE",
Patch(
Consumable_Master,
LookUp(
Consumable_Master,
Value(Dropdown1.Selected.Title) = Value(Title)
),
{Purchase_x0020_Qty: Value(DataCardValue29.Text) + Value(Dropdown1.Selected.Purchase_x0020_Qty)}
),
"ISSUE",
Patch(
Consumable_Master,
LookUp(
Consumable_Master,
Value(Dropdown1.Selected.Title) = Value(Title)
),
{Issue_x0020_Qty: Value(DataCardValue29.Text) + Value(Dropdown1.Selected.Issue_x0020_Qty)}
)
);
SubmitForm(Transaction_form);

 

 

 

this is the code for submit form.Here if Value(DataCardValue29.Text) is Qty requested. This should be less than stock available.If he entered value  greater than  available stock .The above process should be terminated and it should notify his stock is less.

 

please suggest a formula.

Categories:
I have the same question (0)
  • v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @likhith117,

    Do you want to validate the if the DataCardValue29.Text is less or greater than the available stock?

    Could you please share a bit more about the scenario?

    I think you just need to add a more If() statement into the Patch() function, please modify your formula as below:

     

    If(Value(DataCardValue29.Text)<Value(Dropdown1.Selected.Purchase_x0020_Qty),
     Value(DataCardValue29.Text) + Value(Dropdown1.Selected.Purchase_x0020_Qty),
     Notify("Your stock is less, please reduce your quantity request!",NotificationType.Error)
     )

     

    Please add this If() statement into each expression including the DataCardValue29.Text

    Switch(
    DataCardValue26.Selected.Value,
    "PURCHASE",
    Patch(
    Consumable_Master,
    LookUp(
    Consumable_Master,
    Value(Dropdown1.Selected.Title) = Value(Title)
    ),
    {Purchase_x0020_Qty: If(Value(DataCardValue29.Text)<Value(Dropdown1.Selected.Purchase_x0020_Qty),Value(DataCardValue29.Text) +Value(Dropdown1.Selected.Purchase_x0020_Qty),Notify("Your stock is less, please reduce your quantity request!",NotificationType.Error))}
    ),
    "ISSUE",
    Patch(
    Consumable_Master,
    LookUp(
    Consumable_Master,
    Value(Dropdown1.Selected.Title) = Value(Title)
    ),
    {Issue_x0020_Qty: If(Value(DataCardValue29.Text)<Value(Dropdown1.Selected.Issue_x0020_Qty),Value(DataCardValue29.Text) +Value(Dropdown1.Selected.Issue_x0020_Qty),Notify("Your stock is less, please reduce your quantity request!",NotificationType.Error))}
    )
    );
    SubmitForm(Transaction_form);

  • likhith117 Profile Picture
    68 on at

    Yes I need to validate.

    In the shared screen shots you can find the details.

    In The above formula the Type has Issue and Purchase.

    If type is selected purchase there should be no objection .

    But if the issued is selected and stock is less than what he entered then it should notify and terminate the patching process above.

    Screenshot (292).png
    Screenshot (291).png
  • v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @likhith117,

    Okay, do you want to validate the DataCardValue29.Text and check if it is less than stock when Issue is selected?

    If so, you just need to put the validation formula into the second Patch().

    Not sure if this Dropdown1.Selected.Issue_x0020_Qty is your available stock, you should compare the DataCardValue29.Text with your available stock.

    Switch(
    DataCardValue26.Selected.Value,
    "PURCHASE",
    Patch(
    Consumable_Master,
    LookUp(
    Consumable_Master,
    Value(Dropdown1.Selected.Title) = Value(Title)
    ),
    {Purchase_x0020_Qty: Value(DataCardValue29.Text) + Value(Dropdown1.Selected.Purchase_x0020_Qty)}
    ),
    "ISSUE",
    Patch(
    Consumable_Master,
    LookUp(
    Consumable_Master,
    Value(Dropdown1.Selected.Title) = Value(Title)
    ),
    {Issue_x0020_Qty: If(Value(DataCardValue29.Text)<Value(YourAvailableStock),Value(DataCardValue29.Text) +Value(Dropdown1.Selected.Issue_x0020_Qty),Notify("Your stock is less, please reduce your quantity request!",NotificationType.Error))}
    )
    );
    SubmitForm(Transaction_form);

     

  • likhith117 Profile Picture
    68 on at

    Thank you .

     

    Switch(
    DataCardValue26.Selected.Value,
    "PURCHASE",
    Patch(
    Consumable_Master,
    LookUp(
    Consumable_Master,
    Value(Dropdown1.Selected.Title) = Value(Title)
    ),
    {'Purchase Qty': Value(DataCardValue29.Text) + Value(Dropdown1.Selected.'Purchase Qty')}
    ),
    "ISSUE",
    Patch(
    Consumable_Master,
    LookUp(
    Consumable_Master,
    Value(Dropdown1.Selected.Title) = Value(Title)
    ),
    {'Issue Qty': If(Value(DataCardValue29.Text)<Value(Dropdown1.Selected.'Closing Qty'),Value(DataCardValue29.Text) +Value(Dropdown1.Selected.'Issue Qty'),Notify("Your stock is less, please reduce your quantity request!",NotificationType.Error))}
    )
    );
    SubmitForm(Transaction_form);

     

    Used this formula but if   stock is less it is notifying the message and even form  getting submitted.This should not happen and also it is reseting the issue qty In sharepoint list to 1.

    The form should terminate if notification comes. But Its getting submitted.Please reply with answer.

     

    @v-qiaqi-msft 

  • v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @likhith117,

    If you want to terminate the form submit once one of the condition is not satisfied, I think we should change a little bit of the formula.

    If(
     DataCardValue26.Selected.Value = "PURCHASE",
     Patch(
     Consumable_Master,
     LookUp(Consumable_Master,Value(Dropdown1.Selected.Title) = Value(Title)),
     {Purchase_x0020_Qty: Value(DataCardValue29.Text) + Value(Dropdown1.Selected.Purchase_x0020_Qty)}
     ),
     If(
     DataCardValue26.Selected.Value = "ISSUE",
     If(
     Value(DataCardValue29.Text)>Value(Dropdown1.Selected.'Closing Qty'),
     Notify(
     "Your stock is less, please reduce your quantity request!",
     NotificationType.Error
     ),
     Patch(
     Consumable_Master,
     LookUp(Consumable_Master,Value(Dropdown1.Selected.Title) = Value(Title)),
     {Purchase_x0020_Qty: Value(DataCardValue29.Text) +Value(Dropdown1.Selected.'Issue Qty')}
     )
     ),
     SubmitForm(EditForm1)
     )
    )

    Please put the added If() statement outside the Patch() function.

  • likhith117 Profile Picture
    68 on at

    Hey @v-qiaqi-msft  That's good.

    But its taking time too long.

     

    Can you please tell me a formula for  field limitations.

     

    Like if Stock is 10.

    then IF condition on that data field such that he cannot enter below that number and notify comes.

  • v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @likhith117,

    Just need to set the OnChange property of the DataCardValue29.Text:

    If(Value(DataCardValue29.Text)<Value(Dropdown1.Selected.'Closing Qty'),
     Notify("Your stock is less, please reduce your quantity request!",NotificationType.Error)
     )

    And then set the DisplayMode property of the submit button as below:

    If(Value(DataCardValue29.Text)<Value(Dropdown1.Selected.'Closing Qty'),Disabled,Edit)

    Finally, you could keep your original formula you provided in your issue description.

  • likhith117 Profile Picture
    68 on at

    Hey @v-qiaqi-msft 

    Actually The formuals you listed are not working.

     

    It is not notifying and The displaymode is disabled without even taking the values.

  • v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @likhith117,

    Could you please check the OnChange property from our official doc?

    You should make the TextInput control change so that the formula within the OnChange property could be triggered.

    If you want a solution that works on any scenario, please add a Label and set the Text property as below:

    "Your stock is less, please reduce your quantity request!"

    Set the Visible property of the Label as below:

    If(Value(DataCardValue29.Text)>Value(Dropdown1.Selected.'Closing Qty'),true,false)

    And then set the DisplayMode property of the submit button as below:

    If(Value(DataCardValue29.Text)>Value(Dropdown1.Selected.'Closing Qty'),Disabled,Edit)

     

  • likhith117 Profile Picture
    68 on at

    That's great @v-qiaqi-msft 

    But Its failing one condition.

    Datacard value26 can be anything if type is purchase and here notify should not come.

    It should be only limitation when Type is issue.

     

    Please send formula according to that.

    Its working fine .

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 1,055

#2
Valantis Profile Picture

Valantis 666

#2
11manish Profile Picture

11manish 666

Last 30 days Overall leaderboard