Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Update SP List with values from same list using Patch

(0) ShareShare
ReportReport
Posted on by

nvpc_0-1692412359647.png

the patch is working but only updates yellow part from table a to the VACANCYID. How can I add the blue part from table b the VACANCYID also, i.e. IT0820230002.

 

ClearCollect(colTableA, Filter(TableA, Import = "Yes"));


ForAll(colTableA,
Patch(TableB ,LookUp(TableB, Available = "Yes"),
{ Title: colTableA[@PO].Value,
VacancyNumber: Concatenate(colTableA[@POSID], TableB.BillID), // this is not working, reason I don't know how to reference TableB fields

VacancyNumber: Concatenate(colTableA[@POSID], "test"), // works
Available: false
}

)
)

  • Verified answer
    nvpc Profile Picture
    on at
    Re: Update SP List with values from same list using Patch

    I managed to get this to work using the ForAll see bellow;

    before running code

    nvpc_0-1692490342091.png

    after running code

    nvpc_1-1692490441464.png

    ClearCollect(colImportedRecords, Filter(tableA, import = 1000));
    ForAll(colImportedRecords,
    Patch(TableB ,LookUp(TableB, AVAILABLE = true),
    { PO: colImportedRecords[@PO],
    VACANCYID: Concatenate(colImportedRecords[@POSID], LookUp(TableB, ID = colImportedRecords[@ID]).BILLID),
    AVAILABLE: false
    }
    )
    )

     

  • nvpc Profile Picture
    on at
    Re: Update SP List with values from same list using Patch

    Thank you for your reply, I've tried using your code and is not working.

    nvpc_0-1692481108014.png

    this first error (1st circle) says "A column name "VACANCYID" already exists, so I renamed it "VACANCYID1"

    I also change the PO (two other circles) to ID as PO is not unique. This cleared the errors and I was able to run but no results, see below

    nvpc_1-1692481506372.png

     

  • hroudaadam Profile Picture
    22 on at
    Re: Update SP List with values from same list using Patch

    Hi there!

    First of all - do not use Patch + ForAll -> you can Patch multiple records at once (see https://www.matthewdevaney.com/patch-multiple-records-in-power-apps-10x-faster/).

    Now to your problem... I am no sure I understand you data. However here's an solution that comes to my mind...

    // patching multiple records at once
    Patch( 
     TableB,
     // when patching multiple record you only need columns with changes and with unique key
     ShowColumns(
     // add new column calculated from current and related collections
     AddColumns(
     colTableB,
     "VACANCYID",
     Concatenate(
     LookUp(colTableA, PO = ThisRecord.PO).POSID,
     ThisRecord.BILLID
     )
     ),
     "ID",
     "VACANCYID"
     )
    )

     

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

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

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard