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 / When click a button, c...
Power Apps
Suggested Answer

When click a button, change 2 different list columns simultaneously

(0) ShareShare
ReportReport
Posted on by 758 Season of Giving Solutions 2025
Hi!
 
I have one list that has the date and time available to do some reservations. Then I have another list that contains the columns of the information of the people who writes down in the text label in the power apps. This is how the power apps look right now:
On the right we have the schedule available to do the reservations. I would need that to be sorted from sooner to later to and if its reserved or the date has expired, it's not shown.
 
So when users introduce something in the text labels in the left and select a date, when clicking the button "Envia i confirma" it should change 2 lists:
1. List availability:
Change column "Estat_agenda" from disponible to "Reservada". I think the code will look like this:
Patch(
    'Agenda entrega Documentació',
    LookUp('Agenda entrega Documentació'),
    {
        Estat_agenda:       {Value: "Reservada"},
    }
)
 
2. List Information:
It will get those text labels into this columns list.
How could a unique code unify both lists action?
 
PD: In the first text label "Data de la sol·licitud, would be nice that people gets the today date by default. What should I write there?
 
Thanks for your time!
Categories:
I have the same question (0)
  • Suggested answer
    Kalathiya Profile Picture
    1,862 Super User 2026 Season 1 on at
     
    Yes, you can display only those date/time values that are greater than or equal to today and are still available (not yet booked). This will ensure users only see valid and bookable time slots. 
     
    Gallery - Item Property filter: 
    SortByColumns(
        Filter(
            'Agenda entrega Documentació',
            Estat_agenda.Value = "Disponible" &&
            Dia_reserva >= Today()
        ),
        "Dia_reserva",
        SortOrder.Descending
    )

    Update availability list and create entry in another list with unique reservation ID.

    Also, You can create one ReservationID column so there we will store unique reservation number in both list. 
    Assumed that you have created ReservationID column
     
    Store the ReservationID in temporary variable for use in both list.
    UpdateContext({_genratedReservationID:Text(Now(),"mmddyyyyyhhmmss")});
    Patch(
        'Agenda entrega Documentació',
        GalleryAgenda.Selected,
        {
            Estat_agenda: {Value: "Reservada"},
            ReservationID: _genratedReservationID
        }
    )
    After this patch add below patch code
    Patch('Registre entrega Documentació',
          Defaults('Registre entrega Documentació'),
          { 
               ReservationID:_genratedReservationID, 
               Titol:Gallery.Selected.Title 
          }
    );
     
     
    Note: Please make sure, please update the column name, list name and control based on your setup for above patch code. 
     
    If this response resolves your issue, please mark it as the Verified Answer so it can help other community members as well.
    ---------------------------------------------------------------------------------

    📩 Need more help? Just mention @Kalathiya and I’ll be happy to assist.

    ✔️ If this answer helped you, please tick “Does this answer your question?” so it can be marked as the Verified Answer.

    💛 A Like always motivates me to keep contributing!

  • Charlie Martharper Profile Picture
    758 Season of Giving Solutions 2025 on at
    Hi! Kalathiya 
     
    It says this in the gallery I am trying to sort the columns.
    It says "Dia_Reserva" column doesn't exist when it does.
     
    What do you mean to store the reservationID in temporary variable for use in both list?  I created that column in both lists.
     
    When using first patch i get wrong the colunms
    And the patch below is also wrong:
     
    So I added the today in the text label and it brang the output correctly:
    But the other thins are still remaining.
  • MS.Ragavendar Profile Picture
    6,616 Super User 2026 Season 1 on at
     
    In SortByColumns, the column name must be a string AND must match the internal column name exactly or else go with suggestion (intellisense) from the powerapps.
     
    Sort(
        Filter(
            'Agenda entrega documentació',
            Estat_agenda.Value = "Disponible" &&
            Dia_reserva >= Today()
        ),
        'Dia_reserva',
        SortOrder.Ascending
    )
     
    ✅If this helped, please Accept as Solution to help others ❤️ A Like is appreciated 🏷️ Tag @MS.Ragavendar for follow-ups.

     

  • Suggested answer
    MS.Ragavendar Profile Picture
    6,616 Super User 2026 Season 1 on at
     
    Patch 1 — Update availability list (corrected)
     
    Patch(
        'Agenda entrega documentació', // Your DataSource.
        gblSelectedSlot, // Gallery selection 
        {
            Estat_agenda: { Value: "Reservada" } // Select Actual Columns and Correct Values 
        }
    )
     
    Note : 
    When user selects a slot in the gallery  -  Set(gblSelectedSlot, ThisItem)
     
    Patch 2 — Save reservation details (corrected)

    Patch(
        'Registre entrega Documentació',
        Defaults('Registre entrega Documentació'),
        {
            ReservationID: gblSelectedSlot.ID,
            Titol: gblSelectedSlot.Title,
            Dia_reserva: gblSelectedSlot.Dia_reserva,
            Hora_reserva: gblSelectedSlot.Hora_reserva,
            'Nom pacient': txtNom.Text,
            SIUAC: txtSIUAC.Text,
            'HC pacient': txtHC.Text,
            Observacions: txtObservacions.Text,
            'Data sol·licitud': Today()
        }
    );
     
    ✅If this helped, please Accept as Solution to help others ❤️ A Like is appreciated 🏷️ Tag @MS.Ragavendar for follow-ups.
  • Kalathiya Profile Picture
    1,862 Super User 2026 Season 1 on at
     
    For sorting, as mentioned by Ragavendar, the SortByColumns function requires the internal column name. You can find the internal name by sorting the column in SharePoint and checking the URL. Use that internal name in the same syntax for sorting. Alternatively, you can use the Sort function as described in the post by Ragavendar.
     
     
    Update code: 
     
    Patch(
        'Agenda entrega documentació', // Your DataSource.
        Data_Hores.Selected, // Gallery selection 
        {
            Estat_agenda: { Value: "Reservada" } 
        }
    );
    Patch(
        'Registre entrega Documentació',
        Defaults('Registre entrega Documentació'),
        {
            ReservationID: Data_Hores.Selected.ID,
            Titol: Data_Hores.Selected.Titulo,
            'Data sol·licitud': Today()
        }
    );  //Please make sure replace the column name with your.. Add all the column whatever you want like Titol, ReservationID etc..
    If this response resolves your issue, please mark it as the Verified Answer so it can help other community members as well.
  • Charlie Martharper Profile Picture
    758 Season of Giving Solutions 2025 on at
    Hi! @MS.Ragavendar
     
    I set the OnSelect control gallery as:  Set(gblSelectedSlot, ThisItem)
    The sorting worked fine in the gallery 👍:
     
    The wrong part comes in the button OnSelect control.
    In the second patch it returns an error:
     
    The first patch seemed to be fine, just have to fix the second one.
    Thanks for your answers!
     
     
  • Kalathiya Profile Picture
    1,862 Super User 2026 Season 1 on at
     
    Before second patch put the semicolon ";".  It's missing that's why you are receiving the error. 
    ;
    If this response resolves your issue, please mark it as the Verified Answer so it can help other community members as well.
  • Charlie Martharper Profile Picture
    758 Season of Giving Solutions 2025 on at
    Hi @Kalathiya
     
     
    I tried your code but the second patch is getting it wrong too:
    Patch(
        'Agenda entrega documentació', // Your DataSource.
        Data_Hores.Selected, // Gallery selection
        {
            Estat_agenda: { Value: "Reservada" }
        }
    );
    Patch(
        'Registre entrega Documentació',
        Defaults('Registre entrega Documentació'),
        {
            ReservationID: Data_Hores.Selected.ID,
            Títol: text_SIUAC_1,
            SIUAC:text_SIUAC,
            HCPacient:text_HCPacient,
            Observacions: Text_observacions,
            Data_petició: Today()
        }
    );
    It seems something is not adding up in the second patch
  • Kalathiya Profile Picture
    1,862 Super User 2026 Season 1 on at
     
    You are missing the .Text after the control name in Patch code that's why you are getting the error. (Assuming all the single line of text fields)
     
    Just update the second patch code: 
    Updated Code: 
     
    Patch(
        'Registre entrega Documentació',
        Defaults('Registre entrega Documentació'),
        {
            ReservationID: Data_Hores.Selected.ID,
            Títol: text_SIUAC_1.Text,
            SIUAC:text_SIUAC.Text,
            HCPacient:text_HCPacient.Text,
            Observacions: Text_observacions.Text,
            Data_petició: Today()
        }
    );
    If this response resolves your issue, please mark it as the Verified Answer so it can help other community members as well.
  • Suggested answer
    MS.Ragavendar Profile Picture
    6,616 Super User 2026 Season 1 on at
     
    Patch(
        'Registre entrega Documentació',
        Defaults('Registre entrega Documentació'),
        {
            ReservationID: Data_Hores.Selected.ID,
            Títol: text_SIUAC_1, // This is failing because for the Text column you are passing the control (object) which doesnt accept hence its giving error instead of control if its text box you should pass controlname.Text same for the all the columns.
            SIUAC:text_SIUAC,
            HCPacient:text_HCPacient,
            Observacions: Text_observacions,
            Data_petició: Today()
        }
    );
     
    As mentioned earlier Provde the formula like this
     
    Patch(
        'Registre entrega Documentació',
        Defaults('Registre entrega Documentació'),
        {
            ReservationID: Data_Hores.Selected.ID,
            Títol: text_SIUAC_1.Text,
            SIUAC:text_SIUAC.Text,
            HCPacient:text_HCPacient.Text,
            Observacions: Text_observacions.Text,
            Data_petició: Today()
        }
    );
     
    ✅If this helped, please Accept as Solution to help others ❤️ A Like is appreciated 🏷️ Tag @MS.Ragavendar for follow-ups.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 516

#2
WarrenBelz Profile Picture

WarrenBelz 450 Most Valuable Professional

#3
Vish WR Profile Picture

Vish WR 448

Last 30 days Overall leaderboard