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 / Can't patch more than ...
Power Apps
Unanswered

Can't patch more than two data sources with if function

(0) ShareShare
ReportReport
Posted on by

Hi all, 

 

I can't seem to Patch more than two data sources in a single button on select. Is it becuase of my If function?

 

I've tried writting it a few times in different ways, but each time it only ever patches to my first two data sources. Such as using only one If statement and putting all three true patch values in there, but again, no luck. 

 

 

If(
 Or(
 DocumentTypeSelector.SelectedText.Value = "02 - Assembly / Drawing",
 DocumentTypeSelector.SelectedText.Value = "04 - Part / Drawing"
 ),
 Patch(
 IERMasterDocuments,
 Defaults(IERMasterDocuments),
 {
 PartNumber: GeneratedPN.Text,
 CreatedOn: CreatedOn1.Text,
 CreatedBy: CreatedBy1.Text,
 DocumentType: DocumentTypeSelector.Selected.Result,
 System: SystemTypePrefix.Text,
 Project: ProjectTypeSelector.Selected.Result,
 ProjectUniqueNumber: ProjectUnique2.Text,
 Release: IssueInput.Text,
 'Status (crec2_status)': StatusInput.Text,
 Description: DescriptionInput.Text,
 Notes: NotesInput.Text,
 Barcode: GeneratedPN.Text,
 Location: LocationInput.Text,
 StockLevel: Value(QuantityInput.Text),
 Cost: Value(CostInput.Text),
 VendorCost: Value(VendorCostEachInput.Text)
 }
 );,
 false
);
If(
 Or(
 DocumentTypeSelector.SelectedText.Value = "02 - Assembly / Drawing",
 DocumentTypeSelector.SelectedText.Value = "04 - Part / Drawing"
 ),
 Patch(
 IERStockHistories,
 Defaults(IERStockHistories),
 {
 Title:"New Stock",
 PartNumber:GeneratedPN.Text,
 Quantity:Value(QuantityInput.Text),
 CostEach:Value(CostInput.Text),
 CostTotal:Value(CostInput*QuantityInput.Text),
 EffectiveCost:Value(CostInput*QuantityInput.Text),
 TakenBy:User().FullName,
 Date:Text(Now(),"dd-mmm-yy"),
 Reason:"Restocked"
 }
 );,
 false
);
If(
 Or(
 DocumentTypeSelector.SelectedText.Value = "02 - Assembly / Drawing",
 DocumentTypeSelector.SelectedText.Value = "04 - Part / Drawing"
 ),
 Patch(
 IERPartsVendors,
 Defaults(IERPartsVendors),
 {
 PartNumber: GeneratedPN.Text,
 Vendor: VendorPicker.Selected.Result,
 VendorPN: VendorPNInput.Text,
 VendorDescription: VendorDesInput.Text,
 VendorCost: Value(VendorCostInput.Text),
 VendorQty: Value(VendorQtyInput.Text),
 VendorCostEach: Value(VendorCostEachInput.Text)
 }
 );,
 false
);
If(
 Or(
 DocumentTypeSelector.SelectedText.Value = "02 - Assembly / Drawing",
 DocumentTypeSelector.SelectedText.Value = "04 - Part / Drawing"
 ),
 false,
 Patch(
 IERMasterDocuments,
 Defaults(IERMasterDocuments),
 {
 PartNumber: GeneratedPN.Text,
 CreatedOn: CreatedOn1.Text,
 CreatedBy: CreatedBy1.Text,
 DocumentType: DocumentTypeSelector.Selected.Result,
 System: SystemTypePrefix.Text,
 Project: ProjectTypeSelector.Selected.Result,
 ProjectUniqueNumber: ProjectUnique2.Text,
 Release: IssueInput.Text,
 'Status (crec2_status)': StatusInput.Text,
 Description: DescriptionInput.Text,
 Notes: NotesInput.Text,
 Barcode: GeneratedPN.Text
 }
 );
);

Patch(
 IERMasterHistories,
 Defaults(IERMasterHistories),
 {
 PartNumber:GeneratedPN.Text,
 Change:"Initial Creation",
 ChangeBy:User().FullName,
 ChangeOn:Text(Now(),"dd-mmm-yy")
 }
);
Set(
 varInfoMode,
 "0"
);
Reset(DocumentTypeSelector);
Reset('01_SystemTypeSelector');
Reset('02_SystemTypeSelector');
Reset('05_SystemTypeSelector');
Reset('07_SystemTypeSelector');
Reset('04_SystemTypeSelector');
Reset('10_SystemTypeSelector');
Reset(ProjectTypeSelector);
Reset(DescriptionInput);
Reset(NotesInput);
Reset(CreatedOn1);
Reset(LocationInput);
Reset(QuantityInput);
Reset(CostInput);
Reset(VendorPicker);
Reset(VendorPNInput);
Reset(VendorDesInput);
Reset(VendorCostInput);
Reset(VendorQtyInput);
UpdateContext({Checkbox2Value: false});
Navigate(MainScreen)

 

 

Can some one please point out why I can't get this to work? I've been trying to figure out a solution for two days now!

 

Thanks, 

Luke.  

Categories:
I have the same question (0)
  • LukeAThomas Profile Picture
    on at

    Infact, I removed the If function altogether, and I can still only patch the first two data sources, so I guess the question is more, how do I patch more than two different data sources? 

     

    I've been searching and I can't seem to find the answer anywhere.... 

  • KeithAtherton Profile Picture
    3,709 Most Valuable Professional on at

    Hi @LukeAThomas. To confirm, the first two data sources (IERMasterDocuments, IERStockHistories) are patched OK but the rest (IERPartsVendors, IERMasterDocuments, IERMasterHistories) are not?

     

    Are the commands after the Patch calls (control Resets, Navigate, etc) working OK?

     

    One test to try would be to call the Patch statements without If blocks around them to identify if the Patch commands themselves are not working as expected.

  • iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    Use the Monitor function in Power Apps, then press the button, look at the log in Monitor to see what the issue is, I suspect the later patches are throwing errors but you're not seeing them.

     

    Additionally I would recommend that you should also be implementing the IfError() function whenever you use patch, as you have no guarantee that the patch worked successfully, but then you are resetting controls and navigating away afterwards. We use IfError to notify the user (or do something else) if there was an error while patching.

     

    Cheers,

    Sancho

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 March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 551

#2
WarrenBelz Profile Picture

WarrenBelz 430 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 298

Last 30 days Overall leaderboard