Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building 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:
  • CP-23071818-0 Profile Picture
    107 on at
    Checking for combination of 2 field values in SP list before Patch code
    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)
  • WarrenBelz Profile Picture
    146,524 Most Valuable Professional on at
    Checking for combination of 2 field values in SP list before Patch code
    So is this now solved ?
  • CP-23071818-0 Profile Picture
    107 on at
    Checking for combination of 2 field values in SP list before Patch code
    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
    146,524 Most Valuable Professional on at
    Checking for combination of 2 field values in SP list before Patch code
    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
    Checking for combination of 2 field values in SP list before Patch code
     
     
    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. 
     
     
  • CP-23071818-0 Profile Picture
    107 on at
    Checking for combination of 2 field values in SP list before Patch code
    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
    Checking for combination of 2 field values in SP list before Patch code
    Checkbox2_1 is in Gallery 1 thats the only control in it 
     
    the remaining control (listed int he patch) are in Form1_1
     
     
  • WarrenBelz Profile Picture
    146,524 Most Valuable Professional on at
    Checking for combination of 2 field values in SP list before Patch code
    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

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,524 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,906 Most Valuable Professional

Leaderboard