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 / Patching Selections fr...
Power Apps
Unanswered

Patching Selections from Checkbox's from 1 App's Gallery to another Table

(1) ShareShare
ReportReport
Posted on by 107
I am working on trying to edit the OnSelect of a Form Submit button in my App ECI Manager where when i submit the data in the form fields it Will not only submit the field data to Table they are originally from but ALSO input Specific columns from this information AND Selections from a Check box Gallery in Gallery2 as individual records in ECI_Dies (Table 3)
 
Below is the OnSelect statement originally it was just "SubmitForm(Form1)"
 
SubmitForm(Form1);ForAll(ClearCollect(Collection1,CurrentItem),Patch(ECI_Dies,Defaults(ECI_Dies),{ECI_ID:Value(SelectedRecordTitle1.Text),Product:Value(DataCardValue9.SelectedText),ECI_Level:Value(DataCardValue3.Text),'Trial?':Value(DataCardValue2.SelectedItems),Cavity:Value(DataCardValue1.SelectedItems),Content:Value(DataCardValue4.Text),DieNum:Gallery2.Selected})
 
I have never done a patch before so I am sure syntax is all wrong. Currently this is giving errors saying certain fields are one type of data needing another like Number or Text
 
For starters is it even possible to patch the selections into individual record items of another table so when i open that tables App the new records will be there?
 
Should i be using a Patch or some other Function?
 
Modern Controls are off and the Submit button is the automatically generated button provided by Powerapps when creating an App based off the Table if that makes any difference. 
Categories:
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    53,414 Super User 2025 Season 2 on at
    Hi 
     
    So a few things to talk about. Well first thank you for posting your code :-) that helps. The new Viewer is BAD so if you look at your post nothing is wrapped so I had to copy it out to even read it (not your fault)
     
    So here is your code cleaned up
    1) you should NOT put your submit and your Forall in the same place. Why? because if the Submitform fails, you are going to be linking non-existing parent records.
    You should use the OnSuccess property of the Form to do your ForAll
    Or use the OnError to log that the parent failed, but now you dont have missing parents / children
     
    2) I have no idea what you are trying to do in your forall, none of this code is valid but going by what you told me its different than what you are trying to do.
    Let me explain what your code is trying to do
     
    Loop through a Collection called Collection 1, that you are creating for the ... not sure what CurrentItem is
    And then you immediately do a Patch, but your patch isn't using any data from the Collection, just the form so let's do this again (see below)
     
    3) However, its incredibly important if you want us to tell what you are doing wrong you have to share a picture (at least) of the Code Errors, because if you are having Value / field issues, we need to know which ones and for each one, tell us the Field Type in SharePoint/Dataverse so we can figure it out. Right now you are converting everything to a number.
    SubmitForm(Form1);
    
    ForAll(ClearCollect(Collection1,CurrentItem),
       Patch(ECI_Dies,
    	Defaults(ECI_Dies),
    	{
    		ECI_ID:Value(SelectedRecordTitle1.Text),
    		Product:Value(DataCardValue9.SelectedText),
    		ECI_Level:Value(DataCardValue3.Text),
    		'Trial?':Value(DataCardValue2.SelectedItems),
    		Cavity:Value(DataCardValue1.SelectedItems),
    		Content:Value(DataCardValue4.Text),
    		DieNum:Gallery2.Selected
    	}
      )
    );
    
    //In your button OnSelect
    
    SubmitForm(Form1);
    
    
    // In your OnSuccess of the Form1
    
    // FIRST it seems like you expect to patch multiple records, but can you explain exactly
    where they come from (like a picture, code, something)
    
    1) From the Form, you only have 1 record, but then you have multiple "Parts" in another Gallery
    2) Are you really creating multiple records from the Gallery2 selections or from parts in Form1
    or will Form1 create multiple Child record and the child records use some of the gallery data?
    
    If Gallery 2 is the master list of child records and parts are coming from Form1 (maybe even
    duplicated across each child record then do this)
    
    ForAll(Filter(Gallery2.AllItems, SomeFieldChecked.Value = true),
      Patch(ECI_Dies,
    	Defaults(ECI_Dies),
    	{ 
           FieldFilledWithGallery2Data: ThisRecord.FieldName.Value or whatever,
           FieldFilledWithForm1Data: Value(SelectedRecordTitle1.Text)
        }
      )
    );
  • CP-23071818-0 Profile Picture
    107 on at
    FLMike, here is some additional information you requested. I'm sorry i cant get you images of the actual errors as I use Snipping tool and impossible for me to keep the cursor on the fields to show their errors but pretty much they all say expecting a Record but got a Number instead. (just like you say in your reply). I hope I answers below explain things more clearly
     
    but lets skip down to your last questions talking about the OnSuccess
    Below is a picture of the App this App is based off of a Table (Table_ECIs, obsured by the input window)
    to the far right is a Gallery of Checkboxs (datasource Table_Dies) 
     
    2) Are you really creating multiple records from the Gallery2 selections or from parts in Form1
    or will Form1 create multiple Child record and the child records use some of the gallery data?
    In this form will be 1 record that goes to Table_ECIs but i want to create Multiple Child Records in a THIRD Table called ECI_Dies where the fields you see from my original code are duplicated and then 4 additional date fields (additional metadata) will be updated in the THIRD table to track progress of the individual Dies. these multiple records i want to be created based on the checks that are selected in the gallery to the right. 
     
    When an ECI is created some 1 time background work is required ot be completed, this is handled by this current App you see here. from there the status of each individual die must be tracked so that we can establish a history on When certain change points were completed and started FOR EACH DIE. 
     
    to provide an example: I create a new ECI and select only 3 of 12 available dies. when i hit submit 3 new records are to appear in Table 3. my image i expect the Product / Content/ECI ID/Level to be 3 rows of repeat information where Die numbers are what is different on each row? 
     
  • CP-23071818-0 Profile Picture
    107 on at
    Original value in OnSuccess of Form1 is 

    UpdateContext({ CurrentItem: Self.LastSubmit, editMode: false, newMode: false })
     
    I Changed it to the example you provided, I also tried 'Checkbox2.value = true' I am intentionally limiting the number of fields 
    I want to Patch until I get the statement to be error free before I add more fields
     
    Also just for clarification RecordsGallery1 is left side gallery containing records for Table_ECIs and Gallery1 is Die numbers
    sourced from Table_Dies.
     
    Here is what I put in OnSuccess
     
     ForAll(Filter(Gallery1.AllItems, Checkbox2.Value = true),
      Patch(ECI_Dies,
            Defaults(ECI_Dies),
      {
        DieNum:ThisRecord.Checkbox2.Text,
        ECI_ID:Value(SelectedRecordTitle1.Text)
      }
      )
     )
     
    3rd Edit:

    I neglected a Comma and putting it in the correct spot removed the initial errors in the the statement above.
    Upon TESTING I editted the first record AACT-1002 and check boxed a couple dies. the Error i recieved in test mode
    "AACT 1002 can not be converted into a number" where the error is located at the Value(SelectedRecordTitle1.Text)

    4th Edit,

    OK I revised OnSuccess Statement to
    ForAll(Filter(Gallery1.AllItems, Checkbox2.Value = true),
     Patch(ECI_Dies, Defaults(ECI_Dies),
      {
        DieNum: ThisRecord.Checkbox2.Text,
        ECI_ID:SelectedRecordTitle1.Text
      }
      )
     )

    It now patches the data in the field into Table ECI_Dies. However I believe since i removed

    UpdateContext({ CurrentItem: Self.LastSubmit, editMode: false, newMode: false })

    From the original code the submit button does not exit edit mode and instead you can continuously click and submit
    the same information over and over. I assume i just need to add this back after the patch?

     

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 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard