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 / Replace the values of ...
Power Apps
Unanswered

Replace the values of a SP list field

(0) ShareShare
ReportReport
Posted on by 2,297

My app is connected to a SharePoint List "Investments".

 

I want to replace the values of the field "Cod_Projeto_key" when the variable "CodigoProjeto" is different from "DataCardValue4_1.Text" and the user clicks a button.

 

So, if CodigoProjeto is "123" and "DataCardValue4_1.Text" is "1234", then ALL the records equal to "123" in the field "Cod_Projeto_key" should be replaced by "1234" in list "Investments".

 

I'm trying a formula for the OnSelect of the button with Lookup, Replace, Update, etc. but can't find one that works.

Categories:
I have the same question (0)
  • eka24 Profile Picture
    20,925 on at

    Does it mean the column in the Table can contain only one figure example 123 for all the rows in the column? Or just that particular row

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • WebPortal Profile Picture
    2,297 on at

    No, the SP list may have something like:

     

    Cod_Pojeto_key | Other column | Another column

    123  |  xxx |  sss

    456  | abc  | xpt

    123  | def  | yio

     

    I want to replace the values of the column "Cod_Projeto_key" where it is currently 123 by 1234 for example.

    So, this would replace the values on row 1 and 3 above.

  • KrishnaV Profile Picture
    5,023 on at

    Hi @WebPortal ,

     

    try this in onSelect property of the button:

    if(Cod_Project_key <> CodigoProjeto,
    ForAll(
     RenameColumns(Filter(Investments, Cod_Project_key = 123), "ID", "ID1"),
     Patch(
     Investments,
     LookUp(Investments, ID = ID1), // find the record you want to update in your another List
     Cod_Project_key = 1234
     )
    ))

     
    I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

    Regards,
    Krishna
    If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.

     

  • WebPortal Profile Picture
    2,297 on at

    Hi @KrishnaV 

     

    Thanks, I get the whole formula underlined in red:

     

    If(DataCardValue4_1.Text <> CodigoProjeto;
    ForAll(
     RenameColumns(Filter(Investments; Cod_Project_key = CodigoProjeto); "ID"; "ID1");
     Patch(
     Investments;
     LookUp(Investments; ID = ID1); // find the record you want to update in your another List
     Cod_Project_key = DataCardValue4_1.Text
     )
    ))

     

     

  • KrishnaV Profile Picture
    5,023 on at

    Hi @WebPortal ,

     

    Could you share with me the error screen with the error description on that?


    I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

    Regards,
    Krishna
    If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.

  • eka24 Profile Picture
    20,925 on at

    Try

    Patch( Datasource,
    First( Filter( Datasource, Cod_Projeto_key <>CodigoProjeto) ),

    { Cod_Projeto_key: DataCardValue4_1.Text} )

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • WebPortal Profile Picture
    2,297 on at

    @eka24 it is replacing the wrong rows 🙂

  • KrishnaV Profile Picture
    5,023 on at

    Hi @WebPortal ,

     

    try this:

     

    Patch( Datasource,
    First( Filter( Datasource, (Value(Cod_Projeto_key) <> Value(CodigoProjeto) And Cod_Project_key = 123) ),
    { Cod_Projeto_key: DataCardValue4_1.Text} )

     


    I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

    Regards,
    Krishna
    If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.

  • eka24 Profile Picture
    20,925 on at

    Change the equation sign

    Patch( Datasource,
    First( Filter( Datasource, Cod_Projeto_key =CodigoProjeto) ),

    { Cod_Projeto_key: DataCardValue4_1.Text} )

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • KrishnaV Profile Picture
    5,023 on at

    Hi @WebPortal ,

     

    In this formula I made some changes and tested in my local:

    If(Value(DataCardValue4_1.Text) <> Value(CodigoProjeto),
    ForAll(
     RenameColumns(Filter(Investments; Cod_Project_key = CodigoProjeto); "ID"; "ID1"),
     Patch(
     Investments;
     LookUp(Investments; ID = ID1), // find the record you want to update in your another List
     Cod_Project_key = Value(DataCardValue4_1.Text) // if the filed is integer remove Value if it is single line of text
     )
    ))


    I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

    Regards,
    Krishna
    If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.

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

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 305 Most Valuable Professional

#2
11manish Profile Picture

11manish 212

#3
Valantis Profile Picture

Valantis 167

Last 30 days Overall leaderboard