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 / Copying records/rows i...
Power Apps
Unanswered

Copying records/rows in a sharepoint list and then modifying a single column in powerapps

(0) ShareShare
ReportReport
Posted on by 179

Hey all,

I'm struggling with doing something in powerapps.

I have a sharepoint list with rows and columns. Let us call this sharepoint list: Table

Table will have several records for an individual person and sometimes they may need to add more records. This is if the fail the test.

My goal is to have the powerapp function in this way:

Student clicks a button, the button has on select code that will go to Table and then copy all rows for that student. Then the powerapp will update the milestoneID value for that record to match the new attempt's milestoneID

I have the following code for "onvisible" of the screen.

Patch(
'table',
Filter(Last('Table',MilestoneID=SafeMilestoneTitle)),
{
MilestoneID: SafeMilestoneTitle
}
);

However, this doesn't work. It says that it can't evaluate error and number.

If I take out the last function, it will not give an error but clicking the button will not modify the sharepoint list of Table.

Any advice?

I know I must be missing something simple.

The context of this is:

The student needs to go back to the powerapp and then re-enter the same information as before, but it needs to be associated with a new milestoneID 


Categories:
  • WBADAM03 Profile Picture
    179 on at

    I can't seem to edit my above post but I did finally get an error with this:

    Patch(
    'Table',
    Last(Filter('Table',MilestoneID = SafeMilestoneTitle),
    {
    MilestoneID: SafeMilestoneTitle
    }
    ));

    It says it can't compare between number and string. I believe safemilestoneID is a string. Any advice?

  • WBADAM03 Profile Picture
    179 on at

    safemilestoneID is a number*

  • Anonymous_Hippo Profile Picture
    1,247 Super User 2024 Season 1 on at

    Hello @WBADAM03 ,

     

    Can you try the following formula

    Patch(
     'table',
     LookUp('Table', MilestoneID = SafeMilestoneTitle),
     {
     MilestoneID: SafeMilestoneTitle
     }
    );
    

    Cheers !

     

    __PRESENT__PRESENT

  • madlad Profile Picture
    2,637 Moderator on at

    It looks like in the filter you're comparing MilestoneID and safeMilestoneTitle? Is safeMilestoneTitle a string?

    If yes you'll either need to change the reference, or use the Value function to convert it to a number.

  • WBADAM03 Profile Picture
    179 on at

    The MilestoneID is a sharepoint column in Table that is a single line of text
    SafeMilestoneTitle is a number. 

    This sharepoint list gets used a lot in different apps and powerbi and a flow, so I don't know if I can convert the MilestoneID to a number without breaking it.

    After thinking about this a bit more, I don't need the last function. so I have:


    Patch(
    'phdt - committee',
    Filter('phdt - committee',MilestoneID = Text(SafeMilestoneTitle),
    {
    MilestoneID: Text(SafeMilestoneTitle)
    }
    );

    It gives me a warning about filter on large datasets, but it simply does nothing when I press the button

  • WBADAM03 Profile Picture
    179 on at

    Hey there!

    Thanks for your help. That isn't sadly what I need.

    I believe that lookup will only return the first result, one person may have 8 records I need to retrieve and copy over.

    I also found out that because safemilestonetitle is a number and milestoneID is a string column in sharepoint, powerapps is giving me trouble.

    After thinking about this a bit more, I don't need the last function. so I have:


    Patch(
    'phdt - committee',
    Filter('phdt - committee',MilestoneID = Text(SafeMilestoneTitle),
    {
    MilestoneID: Text(SafeMilestoneTitle)
    }
    );

    It gives me a warning about filter on large datasets, but it simply does nothing when I press the button

  • Anonymous_Hippo Profile Picture
    1,247 Super User 2024 Season 1 on at

    Hello @WBADAM03 ,

     

    You might need to use Forall() to patch the value to all the recorxds that are returned on the filter lets say 4 records are returned then assuming that you need to update all these 4 records you may use the below code :-

    ForAll(
     Filter('phdt - committee', MilestoneID = Text(SafeMilestoneTitle)),
     Patch(
     'phdt - committee',
     ThisRecord,
     {
     MilestoneID: Text(SafeMilestoneTitle)
     }
     )
    );
    

     

    hoping that this works 🙂

     

     

  • WBADAM03 Profile Picture
    179 on at

    Thanks so much Hippo!

    Still having a bit of problem with this one: this function cannot operate on the same data source that is used in forall.

    my full code (For the on select button) is

    (this powerapp has been handled by about 7 people, so the code leaves some to be desired, including my own code lol)


    If(IsBlank(LookUp('phdt - milestones', ULinkID=DemoUlinkID && 'Milestone Name'.Value = "DQE" && 'Attempt number' = 2)),
    UpdateContext({PlusTimerStart: true});
    // Get safe titles and submit:
    UpdateContext({SafeMilestoneTitle: Last('phdt - milestones').Title + 1});
    SubmitForm(Milestone_Form_DQE);

    UpdateContext({SafeDQETitle: Last('phdt - dqes').Title + 1});
    SubmitForm(DQE_Form);
    );


    /*ForAll(
    Patch(
    'phdt - committee', Filter('phdt - committee', MilestoneID = Text(SafeMilestoneTitle),
    {
    MilestoneID: Text(SafeMilestoneTitle)
    }
    )
    );*/

    ForAll(
    Filter('phdt - committee', MilestoneID = Text(SafeMilestoneTitle)),
    Patch(
    'phdt - committee',
    ThisRecord,
    {
    MilestoneID: Text(SafeMilestoneTitle)
    }
    )
    );



  • Anonymous_Hippo Profile Picture
    1,247 Super User 2024 Season 1 on at

    Hello @WBADAM03 ,

     

    Looks like we are having a circular reference, dummy me. Also please refer to this youtube video 

    https://www.youtube.com/watch?v=ljVhCtEAH2s&t=3s

     

    I was going through this perhaps we don't even need to use forall() and patch

     

    Can you try this

     

    UpdateIf(
     'phdt - committee', 
     MilestoneID = Text(SafeMilestoneTitle), 
     { MilestoneID: Text(SafeMilestoneTitle) }
    );
    

     

    Cheers !

     

  • WBADAM03 Profile Picture
    179 on at

    Hey there! Sorry I didn't reply, I had to actually change my powerapp because I realized the milestoneID wasn't actually assigning the right value. Now that is solved at least!

    That makes sense, I tried to do an on-visible clearcollect to pull all the committee members matching the milestoneID and then putting the update source as the sharepoint list. It didn't throw me an error, but it didn't do anything when the button was pressed.

    The code you provided doesn't give an error like usual, but it does say "this formula has side effects and cannot be evaluated". When I press the button, it doesn't modify the sharepoint list in any way.

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 271

#3
Mohsin Ali Profile Picture

Mohsin Ali 239

Last 30 days Overall leaderboard