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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to stop patch with...
Power Apps
Unanswered

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

(0) ShareShare
ReportReport
Posted on by 2

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)
               
            }
        )
    )
);
Categories:
I have the same question (0)
  • VishalJhaveri Profile Picture
    1,167 Moderator on at

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

  • MIA27 Profile Picture
    2 on at

    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

  • Nigel_Purvis Profile Picture
    6 on at

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

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

     

    Rgds

    Nigel

     

  • mmbr1606 Profile Picture
    14,605 Super User 2025 Season 2 on at

    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

  • VishalJhaveri Profile Picture
    1,167 Moderator on at

    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)
     }
     )
     )
     )
    );

  • MIA27 Profile Picture
    2 on at

    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.

     

     

  • Verified answer
    iAm_ManCat Profile Picture
    18,228 Most Valuable Professional on at

    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)
     }
     )
     )
     )
    );
  • Verified answer
    mmbr1606 Profile Picture
    14,605 Super User 2025 Season 2 on at

    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)
     }
     )
     )
     )
    );
    

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard