Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Unanswered

Checking SP list for existence of 2 field values before Patching

(1) ShareShare
ReportReport
Posted on by 107
I have had help on this patch before but I may have broken it and not known what I have changed  
 
In my form1_1 Onsuccess property i have the following code
 
ForAll(
   Filter(
      Gallery1.AllItems, Checkbox2_1.Value = true //for all, filter gallery1 for checked boxes
   ) As _Data, //call this data '_data'
   With(
      {
         _Records:
         Filter(
            ECI_Dies_1,
            dienum = Gallery1.Selected.Checkbox2_1.Text &&
            eci_id = SelectedRecordTitle1_1.Text
         ) //Filter ECI_Dies_1 table for records where dienumber and ECI ID matches Record selections in the form
      },
      If(CountRows(_Records) <1, //If true, then Patch otherwise do nothing
         Patch(
            ECI_Dies_1,
            {
               dienum: _Data.Checkbox2_1.Text,
               eci_id: SelectedRecordTitle1_1.Text,
               product: DataCardValue9.Selected.Value,
               content: DataCardValue4_1.Text,
               eci_level: DataCardValue3_1.Text,
               trial: Checkbox8.Value,
               cavity: DataCardValue2.Selected.Value,
               Priority:DataCardValue11.Selected.Value,
               Purpose:DataCardValue6.Selected.Value,
               request_date:DateValue1.SelectedDate
            } //Data list patching to Eci_dies_1 SP list
         )
      )
   )
);
UpdateContext(
    {
    CurrentItem: Self.LastSubmit,
    editMode: false,
    newMode: false
    } //submit form data to Table_ecis SP list
)
 
This code is supposed to identify which checkbox2_1's are checked then for each of those checked, then
of those being checked does ECI ID and Checkbox2_1 values  occur in ECI_Dies_1 SP list, If they DO then do not patch if they DO NOT 
Then patch, then update\append other form data to Table_ECIs list (not listed because this is the main datasource of the screen)
 
Where i have a problem is the portion of the code ABOVE the patch. I can not get it to stop creating duplicate child records.
 
I have a perfect case in my data that I am testing - the record selected had 6 and 7 unchecked therefore in the original submission ECI_Dies 1 
has only 1 2 3 4 and 5 child records.  if i click the pencil, check the 6 and 7, then click submit. it should only add child records or 6 and 7
but instead it is adding not only for 6 and 7 but another set for 1 through 5
 
 
Putting cursor in my patch just after the first filter code correctly shows i have check boxes for dies 1 through 5 checked. i think where its not working is
after 2nd filter putting my cursor says theres no data. so I believe this is why it continues to patch for all the check boxes
 
 
 
Categories:
  • CP-23071818-0 Profile Picture
    107 on at
    Checking SP list for existence of 2 field values before Patching
    Warren, thank you for the insight! you are correct i am using the Text property 
     
    is it possible to change the structure of the gallery or the checkbox in a way that the result of the Text property can BECOME the value of the control? 
     
    I chose the Gallery\check box method as a way to guarantee they can only choose the correct dies and not Forget dies, enter dies numbers that don't exist yet, enter dies that have been retired and disposed. 
     
    This gallery is sourced to a 2nd SP list to populate. Do you have a suggestion for an alternative method? 
  • WarrenBelz Profile Picture
    146,660 Most Valuable Professional on at
    Checking SP list for existence of 2 field values before Patching
    I believe I raised this some time ago in your last thread - I assume you are referring to the label on the Text box in using Checkbox2_1.Text (which is not the output of the control - Checkbox2_1.Value, but a property of the control). It seems this is not supported with Delegation, so is actually a third reason you are not going to be able to process more than 2,000 items with that process.
  • CP-23071818-0 Profile Picture
    107 on at
    Checking SP list for existence of 2 field values before Patching
    Warren 
     
    Dienum in the Eci_dies_1 SP list is a Single line text column because Metal forging dies are called out as numbers and Resin dies are called out as letters 
  • WarrenBelz Profile Picture
    146,660 Most Valuable Professional on at
    Checking SP list for existence of 2 field values before Patching
    You are limited to 2,000 records anyway within the ForAll Table and also the Gallery cannot contain any more than this unless it is a Delegable filter and the user scrolls all the way down past the 20 sets of 100 to get all the records. I am surprised at the warning though - what type of field is dienum ?
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee
  • CP-23071818-0 Profile Picture
    107 on at
    Checking SP list for existence of 2 field values before Patching
    Warren its nice to hear from you! 
     
    So I get a delegation warning with Checkbox2_1.Text  and I expect this table to grow to over 2000 over time so is there a tweek I can make to this to make it not have the delegation warning?

    Edit: I did test this code and it did infact work for the Case above I just worry about the Delegation warning causing it to not be effective overtime. 
  • WarrenBelz Profile Picture
    146,660 Most Valuable Professional on at
    Checking SP list for existence of 2 field values before Patching
    This code looks a bit familiar from a little while back, Firstly I would suggest you go this way, but your main issue was that you used an As identifier for the gallery and then used Gallery.Selected in the filter. Also if SelectedRecordTitle1_1 is in the gallery, you heed _Data. in front of it.
    ForAll(
       Filter(
          Gallery1.AllItems, 
          Checkbox2_1.Value
       ) As _Data,
       With(
          {
             _Record:
             LookUp(
                ECI_Dies_1,
                dienum = _Data.Checkbox2_1.Text &&
                eci_id = SelectedRecordTitle1_1.Text
             ).dienum
          },
          If(
             IsBlank(_Record),
             Patch(
                ECI_Dies_1,
                {
                   dienum: _Data.Checkbox2_1.Text,
                   eci_id: SelectedRecordTitle1_1.Text,
                   product: DataCardValue9.Selected.Value,
                   content: DataCardValue4_1.Text,
                   eci_level: DataCardValue3_1.Text,
                   trial: Checkbox8.Value,
                   cavity: DataCardValue2.Selected.Value,
                   Priority:DataCardValue11.Selected.Value,
                   Purpose:DataCardValue6.Selected.Value,
                   request_date:DateValue1.SelectedDate
                }            
             )
          )
       )
    );
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee

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,660 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