web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : vI3klFqa06a/+5wnpyQYJC
Power Apps - Building Power Apps
Answered

Repeating Table - Patch the Collection, Create New Record and Patch SharePoint Child List

Like (0) ShareShare
ReportReport
Posted on 24 Sep 2024 18:00:04 by 1,360
Hello,
Two questions: 1. Why are the fields Approval Modification Date and Modification Approver in my gallery clearing the data when I click the save to collection button?
Question 2: Is it possible to populate the new fields in the gallery that my collect function is using to create a new record with any of the last record data in my collection?
 

Picture 1: Repeating Table fields.
When the toggle is set to yes this is the first record in the repeating table.
The value at the top right is set based on a value set on top of the form and is a unique value.
I entered the date and the approver's name but not the reason yet.
 
Below, I entered the reason which then shows the save button and delete button and sets the counter to 1.

Here is where it becomes a problem. When I save the record it clears the date (the default is Today()) and it clears the Approver name but retains the Reason.


A new record is created below the first record in the collection and I would expect the new record to be empty but not the first record.
In regard to the image above is it possible to set the Date field and Approver field to the values saved in the last record in my collection?
 
Below is the logic for what I am doing:

On my parent form I have a button that loads a new form.
This is the formula used in the button.

ClearCollect Logic:
ClearCollect(colAppMod,{CSARefNumb:"", AppModDate:"", AppModApprover:"", AppModReason: ""});
 
 
Patch the collection and create a new blank record:
Patch(

    colAppMod,
    ThisItem,
    {
        CSARefNumb: DataCardValue16.Text,
        AppModReason: AppModReason.Text,
        AppModDate: dteAppModDate.SelectedDate,
        AppModApprover: cboAppModApprover.Selected.DisplayName
    }
);
Collect(
    colAppMod,
    {
        CSARefNumb: "",
        AppModDate: "",
        AppModApprover: "",
        AppModReason: ""
    }
)
 
Save to the child SharePoint list: 
ForAll(
    colAppMod,
    Patch(
        'Approval Modification',
        Defaults('Approval Modification'),
        {
            CSARefNumb: CSARefNumb,
            ModApprovalReason: AppModReason,
            ModApprovalDate: DateTimeValue(AppModDate),
            ModApproverName:{
            '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
            Claims: Concatenate("i:0#.f|membership|",AppModApprover),
            Department: AppModApprover,
            DisplayName: AppModApprover,
            Email: AppModApprover,
            JobTitle: "",
            Picture: ""
        }
        }
    )
)
I have the same question (0)
  • Nirav Raval (Akira28) Profile Picture
    153 Moderator on 24 Sep 2024 at 18:41:38
    Repeating Table - Patch the Collection, Create New Record and Patch SharePoint Child List
    Hi golfnutt82 ,


    From the question and code which is shared,  can you give a try on the below code it works. 
    🤞

     
    Patch(
        colAppMod,
        ThisItem,
        {
            CSARefNumb: DataCardValue16.Text,
            AppModReason: AppModReason.Text,
            AppModDate: dteAppModDate.SelectedDate,
            AppModApprover: cboAppModApprover.Selected.DisplayName
        }
    );

    Collect(
        colAppMod,
        {
            CSARefNumb: Last(colAppMod).CSARefNumb,
            AppModDate: Last(colAppMod).AppModDate,
            AppModApprover: Last(colAppMod).AppModApprover,
            AppModReason: Last(colAppMod).AppModReason
        }
    );

    ForAll(
        colAppMod,
        Patch(
            'Approval Modification',
            Defaults('Approval Modification'),
            {
                CSARefNumb: CSARefNumb,
                ModApprovalReason: AppModReason,
                ModApprovalDate: DateTimeValue(AppModDate),
                ModApproverName: {
                    '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                    Claims: Concatenate("i:0#.f|membership|", AppModApprover),
                    Department: AppModApprover,
                    DisplayName: AppModApprover,
                    Email: AppModApprover,
                    JobTitle: "",
                    Picture: ""
                }
            }
        )
    );
     

    If this post solved your issue, clicking 'Does this answer your question' will help others discover the solution and close the topic. If you found it helpful, a Like would be awesome!


    Regards,
    Nirav J Raval (Akira28)
     
  • golfnutt82 Profile Picture
    1,360 on 25 Sep 2024 at 13:12:58
    Repeating Table - Patch the Collection, Create New Record and Patch SharePoint Child List
    Hello Nirav,
    Thanks for responding with your suggestion.
    I tried it out and what happened was that when I entered a new record and saved it to the collection, it created a duplicate of that record. 
    When I entered another record, it created the record as expected but kept the previous entry and the copy.

     
  • golfnutt82 Profile Picture
    1,360 on 25 Sep 2024 at 13:19:26
    Repeating Table - Patch the Collection, Create New Record and Patch SharePoint Child List
    Collect(
        colAppMod,
        {
            CSARefNumb: Last(colAppMod).CSARefNumb,
            AppModDate: Last(colAppMod).AppModDate,
            AppModApprover: Last(colAppMod).AppModApprover,
            AppModReason: Last(colAppMod).AppModReason
        }
    );
    I like what you provided above.
    While the collection gets populated with the AppModeApprover value but the value still doesnt show in the form field of the gallery, which is confusing.
    When the field is cleared out it leads the user to believe nothing was entered.

     
  • Verified answer
    golfnutt82 Profile Picture
    1,360 on 30 Sep 2024 at 14:11:26
    Repeating Table - Patch the Collection, Create New Record and Patch SharePoint Child List
    The below is how I solved the issue I was experiencing.

    The issue I was having with this was when the save button was pressed and a new record was recreated on the gallery the Modification Approver name would stay in the dropdown, but the date field would retain its value.
    This made it look like nothing was entered so the only value I wanted to carry over to the new record was the CSA Reference Number.
    What I did was I added a label and placed it under the Modification Approver field and the Text property has this ThisItem.AppModApprover
     
    The logic entered in the On Select property of the save button looks as follows:
     
    Patch(
        colAppMod,
        ThisItem,
        {
            CSARefNumb: DataCardValue16.Text,
            AppModReason: AppModReason.Text,
            AppModDate: dteAppModDate.SelectedDate,
            AppModApprover: cboAppModApprover.Selected.DisplayName
        }
    );
    Collect(
        colAppMod,
        {
            CSARefNumb: First(colAppMod).CSARefNumb,
            AppModDate: "",
            AppModApprover: "",
            AppModReason: ""
        }
    )
     

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 714 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 419 Super User 2025 Season 2

#3
developerAJ Profile Picture

developerAJ 243

Last 30 days Overall leaderboard