Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

How to stop patch with notification if To Post Quantity is 0 or Blank

(0) ShareShare
ReportReport
Posted on by

I am using the below code to patch the records.

some time user forgets to input the Qty and click on the button, The records get posted with Blank Qty.

I want to stop patch code to run if the RecQty of any of the row is Null or Empty

I want notification that it cannot post , 

 

Please advise what correction to be done in the below code to obtain this result

 

 

 

ForAll(
    Gallery9.AllItems,
   
    Collect(colAllPartsReceipt,
        Patch(
        TablePartsReceipts, Defaults(TablePartsReceipts),
            {
                RecoNo:(First(Sort(TablePartsReceipts, RecoNo, SortOrder.Descending)).RecoNo)+1,
                RecDate:DatePicker4.Value,
                PartNumber:Upper(Label21.Text),
                PartDescription:Upper(Label24.Text),
                RecQty:Value(TextBox4.Value),
                UnitCost:Value(TextBox4_1.Value),
                Vendor:Upper(TextBox4_2.Value),
                RecRemarks:Upper(TextBox4_3.Value)
               
            }
        )
    )
);
  • Verified answer
    mmbr1606 Profile Picture
    12,108 Super User 2025 Season 1 on at
    Re: How to stop patch with notification if To Post Quantity is 0 or Blank

    hey @MIA27 

     

    try this instead:

    If(
     CountRows(
     Filter(
     Gallery9.AllItems,
     IsBlank(TextBox4.Value) || Value(TextBox4.Value) = 0
     )
     ) > 0,
     Notify("Cannot post record because one or more Received Quantities are empty or zero.", NotificationType.Error),
     ForAll(
     Gallery9.AllItems,
     Collect(
     colAllPartsReceipt,
     Patch(
     TablePartsReceipts,
     Defaults(TablePartsReceipts),
     {
     RecoNo: (First(Sort(TablePartsReceipts, RecoNo, SortOrder.Descending)).RecoNo) + 1,
     RecDate: DatePicker4.Value,
     PartNumber: Upper(Label21.Text),
     PartDescription: Upper(Label24.Text),
     RecQty: Value(TextBox4.Value),
     UnitCost: Value(TextBox4_1.Value),
     Vendor: Upper(TextBox4_2.Value),
     RecRemarks: Upper(TextBox4_3.Value)
     }
     )
     )
     )
    );
    
  • Verified answer
    iAm_ManCat Profile Picture
    18,206 Most Valuable Professional on at
    Re: How to stop patch with notification if To Post Quantity is 0 or Blank

    Ok, so I think that if you do the check for invalid items first, then only patch once that is validated, that should handle the condition you've mentioned:

     

    Clear(numberOfInvalidRows);
    ForAll(
     Gallery9.AllItems,
     If(
     IsBlank(TextBox4.Value) || Value(TextBox4.Value) = 0,
     Collect(numberOfInvalidRows, ThisRecord)
     )
    );
    If(
     CountRows(numberOfInvalidRows)>0,
     Notify("Cannot post record because one of the Received Quantity rows is empty or zero.", NotificationType.Error),
     ForAll(
     Gallery9.AllItems,
     Collect(colAllPartsReceipt,
     Patch(
     TablePartsReceipts, Defaults(TablePartsReceipts),
     {
     RecoNo:(First(Sort(TablePartsReceipts, RecoNo, SortOrder.Descending)).RecoNo)+1,
     RecDate:DatePicker4.Value,
     PartNumber:Upper(Label21.Text),
     PartDescription:Upper(Label24.Text),
     RecQty:Value(TextBox4.Value),
     UnitCost:Value(TextBox4_1.Value),
     Vendor:Upper(TextBox4_2.Value),
     RecRemarks:Upper(TextBox4_3.Value)
     }
     )
     )
     )
    );
  • MIA27 Profile Picture
    on at
    Re: How to stop patch with notification if To Post Quantity is 0 or Blank

    Thank you for your advised code. I applied and it worked, But not the way I wanted.

    For example you can note in the below image I kept 3 records together to test.

    In first I kept RecQty,

    Second I kept Blank to check error notification,

    Third I kept the RecQty

     

    Code ran, it added first and third record and brought the error notification due to second record.

     

    But as I mentioned It will create confusion which record etc, I mean, I want 

     

    If any of the record has RecQty Blank or 0 THEN the code should exit, not run further from the Fx - 

    I dont want to run the patch for the other records , or run any code in that property of Fx.

    Simply it should exit path as well any code after that.

    This will push user first to fix the RecQty and then run the patch all

     

     

    Untitled.png

     

    Kindly guide the modified code.

     

     

  • VishalJhaveri Profile Picture
    1,167 Super User 2025 Season 1 on at
    Re: How to stop patch with notification if To Post Quantity is 0 or Blank

    You can use what @mmbr1606 suggested.

    That is: 

    ForAll(
     Gallery9.AllItems,
     If(
     IsBlank(TextBox4.Value) || Value(TextBox4.Value) = 0,
     Notify("Cannot post record because the Received Quantity is empty or zero.", NotificationType.Error),
     Collect(
     colAllPartsReceipt,
     Patch(
     TablePartsReceipts,
     Defaults(TablePartsReceipts),
     {
     RecoNo: (First(Sort(TablePartsReceipts, RecoNo, SortOrder.Descending)).RecoNo) + 1,
     RecDate: DatePicker4.Value,
     PartNumber: Upper(Label21.Text),
     PartDescription: Upper(Label24.Text),
     RecQty: Value(TextBox4.Value),
     UnitCost: Value(TextBox4_1.Value),
     Vendor: Upper(TextBox4_2.Value),
     RecRemarks: Upper(TextBox4_3.Value)
     }
     )
     )
     )
    );

  • mmbr1606 Profile Picture
    12,108 Super User 2025 Season 1 on at
    Re: How to stop patch with notification if To Post Quantity is 0 or Blank

    hey @MIA27 

     

    please try this:

    ForAll(
     Gallery9.AllItems,
     If(
     IsBlank(TextBox4.Value) || Value(TextBox4.Value) = 0,
     Notify("Cannot post record because the Received Quantity is empty or zero.", NotificationType.Error),
     Collect(
     colAllPartsReceipt,
     Patch(
     TablePartsReceipts,
     Defaults(TablePartsReceipts),
     {
     RecoNo: (First(Sort(TablePartsReceipts, RecoNo, SortOrder.Descending)).RecoNo) + 1,
     RecDate: DatePicker4.Value,
     PartNumber: Upper(Label21.Text),
     PartDescription: Upper(Label24.Text),
     RecQty: Value(TextBox4.Value),
     UnitCost: Value(TextBox4_1.Value),
     Vendor: Upper(TextBox4_2.Value),
     RecRemarks: Upper(TextBox4_3.Value)
     }
     )
     )
     )
    );
    

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

  • Nigel_Purvis Profile Picture
    6 on at
    Re: How to stop patch with notification if To Post Quantity is 0 or Blank

    Try using IsBlank - or in this case !IsBlank (Not IsBlank)

    e.g. if(!IsBlank((TextBox4.Value), Patch .... etc

     

    Rgds

    Nigel

     

  • MIA27 Profile Picture
    on at
    Re: How to stop patch with notification if To Post Quantity is 0 or Blank

    Dear Vishal, 

    Notification line can be added at the end.

     

    But what code to add to check if any of the row's RecQty is null, before patching

     

    pls guide

  • VishalJhaveri Profile Picture
    1,167 Super User 2025 Season 1 on at
    Re: How to stop patch with notification if To Post Quantity is 0 or Blank

    You can use the NOTIFY Function to show the notification about it not being posted.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,658 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,999 Most Valuable Professional

Leaderboard