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 / Checking for combinati...
Power Apps
Unanswered

Checking for combination of 2 field values in SP list before Patch code

(1) ShareShare
ReportReport
Posted on by 107
in my app where i WAS using Dataverse I am switching to SP Lists (long story)
 
in the Onsuccess of my screens form1_1 I have this code
 
ForAll(
    Filter(
        Gallery1.AllItems, 
        Checkbox2_1.Value = true
    ),
    If(
        CountRows(
            Filter(
                ECI_Dies_1,
                dienum= Checkbox2_1.Text,
                eci_id=SelectedRecordTitle1_1.Text
            )
        )<1,
        Patch(
            ECI_Dies_1, Defaults(ECI_Dies_1),
            {
            dienum:ThisRecord.Checkbox2_1.Text,
            eci_id:SelectedRecordTitle1_1.Text,
            product:DataCardValue9.SelectedText.Value,
            content:DataCardValue4_1.Text,
            eci_level:DataCardValue3_1.Text,
            trial:Checkbox8.Value,
            cavity:DataCardValue1_1.Selected.Value
            }
        )
    )
 );
UpdateContext(
    {
    CurrentItem: Self.LastSubmit, 
    editMode: false, 
    newMode: false 
    }
)
 
 
Issue now is Countrows is not delagable with SP List, 
 
  If(
        CountRows(
            Filter(
                ECI_Dies_1,
                dienum= Checkbox2_1.Text,
                eci_id=SelectedRecordTitle1_1.Text
            )
        )<1
 
this piece of the code was preventing duplicate child records being created. since Countrows is not delagable with SP List how could i change that code to prevent Patch from adding data IF combination of Eci_id and Dienum exists in any record of ECI_dies_1 SP list?
 
Some additional information Checkbox2_1 Check and Oncheck on uncheck to add\remove to a collection. I thought maybe the collection could be useful in order to achieve this.
 
Collect(coldieselect,
    {
        Recordgalleryvalue: RecordsGallery1_1.Selected.Title1_1.Text,
        checkboxvalue: Gallery1.Selected.Checkbox2_1.Text
        }
    )
 
Remove(coldieselect, LookUp(coldieselect, checkboxvalue = Gallery1.Selected.Checkbox2_1.Text And Recordgalleryvalue = RecordsGallery1_1.Selected.Title1_1.Text))
 
 
Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    156,100 Most Valuable Professional on at
    I do not know which controls are in the gallery and which are not, so remove the _Data. reference from any that are not in the gallery. Try this
    ForAll(
       Filter(
          Gallery1.AllItems, 
          Checkbox2_1.Value
       ) As _Data,
       With(
          {
             _Records:
             Filter(
                ECI_Dies_1,
                dienum = _Data.Checkbox2_1.Text &&
                eci_id = _Data.SelectedRecordTitle1_1.Text
             )
          },
          If(
             CountRows(_Records) > 0,
             Patch(
                ECI_Dies_1,
                {
                   dienum: _Data.Checkbox2_1.Text,
                   eci_id: _Data.SelectedRecordTitle1_1.Text,
                   product: _Data.DataCardValue9.Selected.Value,
                   content: _Data.DataCardValue4_1.Text,
                   eci_level: _Data.DataCardValue3_1.Text,
                   trial: _Data.Checkbox8.Value,
                   cavity: _Data.DataCardValue1_1.Selected.Value
                }
      ) ) ) )
    You also have Checkbox2_1 mentioned with different references (Value and Text).
     
    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
    Checkbox2_1 is in Gallery 1 thats the only control in it 
     
    the remaining control (listed int he patch) are in Form1_1
     
     
  • CP-23071818-0 Profile Picture
    107 on at
    So I am still getting a delegation warning
     
    {
             _Records:
             Filter(
                ECI_Dies_1,
                dienum = _Data.Checkbox2_1.Text &&
                eci_id = SelectedRecordTitle1_1.Text
             )
          }
     
    "Delegation Warning, the highlighted part of the formala might not work correctly with 'checkbox2_1.text' on large data sets."
     
    I highlighted what it said was being highlighted. 
  • CP-23071818-0 Profile Picture
    107 on at
     
     
    i performed a test and it did not perform the way i had intended. I went to record AACT-0079 and then checked boxes and hit submit. it patched all the values checked where it should have only patched for 1 3 and 4 since 2 was already in the table. 
     
     
  • WarrenBelz Profile Picture
    156,100 Most Valuable Professional on at
    Why are you using .Text on a checkbox (the output is .Value )? I mentioned this in the earlier post. I also assume you have removed the _Data. reference to all controls that are not in the Gallery ?
  • CP-23071818-0 Profile Picture
    107 on at
    So the checkbox in question which is in a Gallery outside of the form container (its a 2nd gallery i manually added) this Gallery is sourced to SP List: Table_dies_1
    the form is sourced to SP List: Table_ecis
    the Patch is directed to SP List: Eci_dies_1 
     
    Im using text there because i have to compare text to text right? 
     
    the .Value of check box is boolean (true false)
    the .text is text the field im comparing to is single line text not boolean. 
     
    if you look at the patch I am asking it to patch the text value of the check box selected to a new record in Eci_dies_1 
     
    am i missing something where the .value of check box can be text?
     
    HOWEVER I did make an error after I posted about delegation warning and before I posted the picture. I changed && to a comma before testing 
     
    changing the comma back to && your code worked, I tested it by submitting a couple records twice and it did not duplicate anything in eci_dies_1 SP list
     
    I got rid of the delegation warning by adding "gallery1." in front of the checkbox2_1.text. 
     
     
  • WarrenBelz Profile Picture
    156,100 Most Valuable Professional on at
    So is this now solved ?
  • CP-23071818-0 Profile Picture
    107 on at
    Yes this is solved but for what ever reason the website pinwheels and freezes when i select a post to suggest as an answer (using Edge)

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 325 Most Valuable Professional

#2
11manish Profile Picture

11manish 165

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 88 Super User 2026 Season 1

Last 30 days Overall leaderboard