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 / Error in patch code ex...
Power Apps
Answered

Error in patch code expecting date value

(2) ShareShare
ReportReport
Posted on by 943 Season of Giving Solutions 2025
I added data_recollida in this formula and it says expecting text value:
When I added like this, all the code goes wrong in this patch. It shoudl fulfill a column in a list in sp date type. Is something wrong with this patch?
Patch(
        'Registre entrega Documentació',
        Defaults('Registre entrega Documentació'),
        {
            ReservationID: Data_Hores.Selected.'Identificador (ID)',
            Títol: text_SIUAC_1.Text,
            Estat_petició: { Value: "En curs" },
            SIUAC: text_SIUAC.Text,
            Hora_recollida: Data_Hores.Selected.Hora_reserva,
            data_recollida: Data_Hores.Selected.Dia_reserva, This part is the one is destroying the patch.
            HC_Pacient: text_HCPacient.Text,
            Observacions: Text_observacions.Text,
            Data_petició: Today()
        }
But if I add DateValue as it was in the first picture I uploaded, it expect text value.
This comes from this other thread but it doesnt reply in there: 
 
Categories:
I have the same question (0)
  • Charlie Martharper Profile Picture
    943 Season of Giving Solutions 2025 on at
    The same happens with a set() control.
    Set(varDiaReserva,   Data_Hores.Selected.Dia_reserva);
    Set(varHoraReserva,  Data_Hores.Selected.Hora_reserva);
     
    I want that when clicking that button, it fulfills 2 text labels.
    But when adding varDiaReserva:
    With varHora_Reserva works correctly, but it seems I have something wrong with the formatting but yesterday all of this worked correctly and when oppening it again it went wrong.
  • Verified answer
    MS.Ragavendar Profile Picture
    7,431 Super User 2026 Season 1 on at
     
    data_recollida is what type of column?
     
    Its a Date / DateTime control value, not Text right?
     
    Give Formula : Text(Data_Hores.Selected.Dia_reserva, "dd/mm/yyyy")
     
    If time also - Text(Data_Hores.Selected.Dia_reserva, "dd/mm/yyyy hh:mm")
     
    Note : Please map the corresponding control name accordingly.
     
    ✅If this helped, please Accept as Solution to help others ❤️ A Like is appreciated 🏷️ Tag @MS.Ragavendar for follow-ups.
  • Suggested answer
    Valantis Profile Picture
    6,735 on at
     
    The error 'Found type Control' means Power Apps is resolving Dia_reserva to a control inside the gallery, not the SharePoint date field. That happens when a control inside the gallery template has the same name as the column.

    Open the gallery template, check if any control is named Dia_reserva, and rename it (e.g. lbl_Dia_reserva). After that, Data_Hores.Selected.Dia_reserva should return the actual date value and the Patch should work without DateValue.

    Also, since you said it worked yesterday and broke today, check if a control got accidentally renamed at some point. That would explain the sudden change.
     

     

    Best regards,

    Valantis

     

    ✅ If this helped solve your issue, please Accept as Solution so others can find it quickly.

    ❤️ If it didn’t fully solve it but was still useful, please click “Yes” on “Was this reply helpful?” or leave a Like :).

    🏷️ For follow-ups  @Valantis.

    📝 https://valantisond365.com/

    💼 LinkedIn

    ▶️ YouTube

  • Suggested answer
    11manish Profile Picture
    3,333 on at
    Your Patch is correct — the issue is that data_recollida column type doesn’t match the value you’re passing
    •  Convert to text OR fix column type
  • Charlie Martharper Profile Picture
    943 Season of Giving Solutions 2025 on at
    Hi!
     
    Its date / date time: 
     
    When adding that formula: You say @MS.Ragavendar it doesnt work:
    @Valantis: Didnt changed anything that's why I am confused :(
    The column in the sharepoint is Dia_Recollida and in the gallery is Data_Disponible so it doesnt has the same name. 
     
    I changed the column from sp from date to text format but it doesnt change the final return. I am always getting it wrong.
     
     
  • Suggested answer
    Kalathiya Profile Picture
    2,456 Super User 2026 Season 1 on at
     
    It's expecting date value but you have passed whole control object due to this you are getting the error. 
     
    Just update like this:
     
    Patch(
            'Registre entrega Documentació',
            Defaults('Registre entrega Documentació'),
            {
                ReservationID: Data_Hores.Selected.'Identificador (ID)',
                Títol: text_SIUAC_1.Text,
                Estat_petició: { Value: "En curs" },
                SIUAC: text_SIUAC.Text,
                Hora_recollida: Data_Hores.Selected.Hora_reserva,
                data_recollida: Data_Hores.Selected.Data_disponible.SelectedDate,
                HC_Pacient: text_HCPacient.Text,
                Observacions: Text_observacions.Text,
                Data_petició: Today()
            }
        );
     
    Assuming the "Data_disponible" - This is date picker control. If it's Label or Text input then your formula like below:
     
    Patch(
            'Registre entrega Documentació',
            Defaults('Registre entrega Documentació'),
            {
                ReservationID: Data_Hores.Selected.'Identificador (ID)',
                Títol: text_SIUAC_1.Text,
                Estat_petició: { Value: "En curs" },
                SIUAC: text_SIUAC.Text,
                Hora_recollida: Data_Hores.Selected.Hora_reserva,
                data_recollida: If(IsBlank(Data_Hores.Selected.Data_disponible.Text), Blank(), Text(Data_Hores.Selected.Data_disponible.Text,"mm/dd/yyyy"),
                HC_Pacient: text_HCPacient.Text,
                Observacions: Text_observacions.Text,
                Data_petició: Today()
            }
        );
     
    //Data_Hores.Selected.Data_disponible.SelectedDate - Instead of this use Data_Hores.Selected.Data_disponible.Text if it's text type control
     
    If(IsBlank(Data_Hores.Selected.Data_disponible.Text), Blank(), Text(Data_Hores.Selected.Data_disponible.Text,"mm/dd/yyyy")
     
    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!

     
  • Suggested answer
    Valantis Profile Picture
    6,735 on at
     
    Just a heads up on the suggestion above the Text() approach might not work here because data_recollida is a Date/Time column in SharePoint. Patching a text string to it will throw a type mismatch.

    The .SelectedDate option could work if Data_disponible is a DatePicker, but referencing a control inside the gallery via Selected is fragile.

    The cleaner fix: what SP list is Data_Hores connected to, and what's the date column called in that list? If it has a date column, you can reference it directly as Data_Hores.Selected.ColumnName and pass that straight to the Patch  no control reference needed, no conversion.
     

     

    Best regards,

    Valantis

     

    ✅ If this helped solve your issue, please Accept as Solution so others can find it quickly.

    ❤️ If it didn’t fully solve it but was still useful, please click “Yes” on “Was this reply helpful?” or leave a Like :).

    🏷️ For follow-ups  @Valantis.

    📝 https://valantisond365.com/

    💼 LinkedIn

    ▶️ YouTube

  • Charlie Martharper Profile Picture
    943 Season of Giving Solutions 2025 on at
    Hi! @Kalathiya
     
    When using 
    Patch(
            'Registre entrega Documentació',
            Defaults('Registre entrega Documentació'),
            {
                ReservationID: Data_Hores.Selected.'Identificador (ID)',
                Títol: text_SIUAC_1.Text,
                Estat_petició: { Value: "En curs" },
                SIUAC: text_SIUAC.Text,
                Hora_recollida: Data_Hores.Selected.Hora_reserva,
                data_recollida: Data_Hores.Selected.Data_disponible.Text,
                HC_Pacient: text_HCPacient.Text,
                Observacions: Text_observacions.Text,
                Data_petició: Today()
            }
        );
     
    When the column is text in the SharePoint, it works but I get the date as "mm/dd/yyyy" would need to get the text as "dd/mm/yyyy". Could I change that?
     
    When the column is date and using:
    Patch(
            'Registre entrega Documentació',
            Defaults('Registre entrega Documentació'),
            {
                ReservationID: Data_Hores.Selected.'Identificador (ID)',
                Títol: text_SIUAC_1.Text,
                Estat_petició: { Value: "En curs" },
                SIUAC: text_SIUAC.Text,
                Hora_recollida: Data_Hores.Selected.Hora_reserva,
                data_recollida: Data_Hores.Selected.Data_disponible.SelectedDate,
                HC_Pacient: text_HCPacient.Text,
                Observacions: Text_observacions.Text,
                Data_petició: Today()
            }
        );
    Its wrong.
  • Kalathiya Profile Picture
    2,456 Super User 2026 Season 1 on at

    Yes, you can change the date format and try it.

    I’m just a bit confused. What type of control is "Data_disponible"? Is it a Text Input, Label, or Date Picker?

    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
    943 Season of Giving Solutions 2025 on at
     
    The are 2 lists 1 with the date availability and one that registers the selected days and hours from the gallery and it patchs the information of the text labels.
     
    Dia_Disponible (text label) is the text label in the gallery that returns the date column information from the SP list Dia_Reserva (SP list column date) and data_recollida (SP list 2 text column) is the column I want the date that is selected in the gallery, thats why that part of the code is:
     
    data_recollida: Data_Hores.Selected.Data_disponible.Text,
     
    Data_hores is the gallery name
    Data_Disponible is the text label in the gallery
    data_recollida is the column in the register list as text (right now).

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 424

#2
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#3
11manish Profile Picture

11manish 290

Last 30 days Overall leaderboard