Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Selecting most recent duplicate SharePoint list entry and updating

(0) ShareShare
ReportReport
Posted on by

Hello Everybody,

 

I am updating a SharePoint list using the code below and this works.

Patch(RCAData, LookUp(RCAData, BatchID = DataCardValue16_2.Text && WaferID = DataCardValue28_2.Text),

The issue I have is it's possible to have duplicate entries in my list and this is a feature I want.

When I try to update the second entry then it updates the first entry instead, as I haven't specified which one to select. The update will always be for the last entry, so I want to do by date order. Can anyone advise the code for this and still keep the lookUp code for BatchID and WaferID.

 

Thank you in advance.

 

Rob

  • Verified answer
    realwillwright Profile Picture
    realwillwright 753 on at
    Re: Selecting most recent duplicate SharePoint list entry and updating

    Sorry it should be Filter rather LookUp

     

    UpdateContext({lclItemToPatch:
     First(
     SortByColumns(
     Filter(RCADate, BatchId = DataCardValue16_2.Text && WaferId = DataCardValue28_2.Text), 
     "Created",
     SortOrder.Descending
     )
     )
    })


    -------------------------------------------------------------------
    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.

  • rob4681 Profile Picture
    rob4681 on at
    Re: Selecting most recent duplicate SharePoint list entry and updating

    Hello again,

    I get the errors in the screen shot below

    rob4681_0-1698225436184.png

    Not too sure it sees my BatchID and WaferID as a table.

     

    Thanks

     

    Rob

  • realwillwright Profile Picture
    realwillwright 753 on at
    Re: Selecting most recent duplicate SharePoint list entry and updating

    Could you try this to populate the variable, I've used SortByColumns rather than Sort. You can then try the patch function as per the previous reply. You will need to populate information into the {} section for the data you need.

     

    Created should be a column in a SharePoint list. 

     

    UpdateContext({lclItemToPatch:
     First(
     SortByColumns(
     Lookup(RCADate, BatchId = DataCardValue16_2.Text && WaferId = DataCardValue28_2.Text), 
     "Created",
     SortOrder.Descending
     )
     )
    })

     

  • rob4681 Profile Picture
    rob4681 on at
    Re: Selecting most recent duplicate SharePoint list entry and updating

    Thank you but the code uses a column for the sort function and this won't compile. I don't know why, I tried different columns.

  • realwillwright Profile Picture
    realwillwright 753 on at
    Re: Selecting most recent duplicate SharePoint list entry and updating

    Hi,

     

    Instead of having a lookup inside the patch, you could set a variable as the lookup and reference that.

     

    UpdateContext({lclItemToPatch:
     First(
     Sort(
     Lookup(RCADate, BatchId = DataCardValue16_2.Text && WaferId = DataCardValue28_2.Text), 
     Created, 
     Descending
     )
     )
    });
    Patch(RCData, lclItemToPatch, {})

     

    I always get Ascending and Descending the wrong way round, but something like this

  • Geeks_D Profile Picture
    Geeks_D 1,169 on at
    Re: Selecting most recent duplicate SharePoint list entry and updating

    Hello, 
    You can try and sort the lookup formula in a descending order 
    Which of the ID is the unique ID for your Data source ? 

     

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,666

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,996

Leaderboard