web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Apps - Error Handling
Suggested answer

Power App Submit Button Error

(2) ShareShare
ReportReport
Posted on by 18

I have developed a Leave Power App that connects to a Microsoft List. The timestamps entered are from staff in the Eastern and Central time zones. I want the times submitted through the Power App to be recorded exactly as they appear on the Microsoft List, without any timezone conversion.
I created the following patch for the "Submit" button, but I keep encountering an error that I cannot resolve. Any assistance would be greatly appreciated. I have attached an image of the error and a view of the app's build. Additionally, I have dropdowns for selecting the date and time.

 

With(

{

// START — build local start timestamp

_h1: Value(HourValue3.Selected.Value),

_m1: Value(MinuteValue3.Selected.Value),

_isPM1: Dropdown14.Selected = "PM",

_h1_24: If(_isPM1 && _h1 <> 12, _h1 + 12, If(!_isPM1 && _h1 = 12, 0, _h1)),

_startLocal:

Date(

Year(DateValue3.SelectedDate),

Month(DateValue3.SelectedDate),

Day(DateValue3.SelectedDate)

) + Time(_h1_24, _m1, 0),

_startUtc: DateAdd(_startLocal, -TimeZoneOffset(_startLocal), TimeUnit.Minutes),

// END — build local end timestamp

_h2: Value(HourValue2.Selected.Value),

_m2: Value(MinuteValue2.Selected.Value),

_isPM2: Dropdown13.Selected = "PM",

_h2_24: If(_isPM2 && _h2 <> 12, _h2 + 12, If(!_isPM2 && _h2 = 12, 0, _h2)),

_endLocal:

Date(

Year(DateValue2.SelectedDate),

Month(DateValue2.SelectedDate),

Day(DateValue2.SelectedDate)

) + Time(_h2_24, _m2, 0),

_endUtc: DateAdd(_endLocal, -TimeZoneOffset(_endLocal), TimeUnit.Minutes)

},

Patch(

'DFS Leave/Overtime Request',

Defaults('DFS Leave/Overtime Request'),

{

// Dates

'Date Started': _startUtc,

'Date Ended': _endUtc,

// Other fields

'Name': DataCardValue1.Text,

'Email Address': DataCardValue17_1.Text,

'Supervisor Email': DataCardValue17.Text,

'Comments': DataCardValue6.Text,

'Time Zone': DataCardValue2.Text,

'Leave/Overtime': Radio1.Selected.Value

}

)

)

 

 

I have the same question (0)
  • Suggested answer
    Robu1 Profile Picture
    1,346 Super User 2025 Season 2 on at
    Power App Submit Button Error
    Hi   ,
     
    Thank you for your question.
     
    Instead of this:
    'Leave/Overtime': Radio1.Selected.Value
     
    Try this:
    'Leave/Overtime': Radio1.Selected.Result
    or
    'Leave/Overtime': Text(Radio1.Selected.Value)
     
    Your formula correctly uses DateAdd() and TimeZoneOffset() to convert local time to UTC. No changes needed there unless you want to store local time directly—in which case, skip the UTC conversion.
     
     
    If this fixes the issue, please mark as resolved to help others with find it.
     
     
    Happy to help. 
     
     
    Robu1
    SuperUser S2:2025
    Moderator
  • Suggested answer
    WarrenBelz Profile Picture
    151,135 Most Valuable Professional on at
    Power App Submit Button Error
    Before I look at anything else in depth, a fundamental issue is that you have chaining dependencies in the same With statement - you need to seperate these like this
    With(
       {   
          _h1: Value(HourValue3.Selected.Value),
          _m1: Value(MinuteValue3.Selected.Value),
          _isPM1: Dropdown14.Selected = "PM",
          _h2: Value(HourValue2.Selected.Value),
          _m2: Value(MinuteValue2.Selected.Value),
          _isPM2: Dropdown13.Selected = "PM"
       },
       With(
          {
             _h1_24: If(!_isPM1 && _h1 = 12, 0, _h1 + If(_isPM1,12)),
             _h2_24: If(!_isPM2 && _h2 = 12, 0, _h2 + If(_isPM2,12))
          },
          With(
             {
                _startLocal: DateValue3.SelectedDate + Time(_h1_24, _m1, 0),
                _endLocal: DateValue2.SelectedDate + Time(_h2_24, _m2, 0)
             },
             With(
                {
                   _startUtc: DateAdd(_startLocal, -TimeZoneOffset(_startLocal), TimeUnit.Minutes), 
                   _endUtc: DateAdd(_endLocal, -TimeZoneOffset(_endLocal), TimeUnit.Minutes)
                },
                Patch(
                   'DFS Leave/Overtime Request',
                   Defaults('DFS Leave/Overtime Request'),
                   {
                      'Date Started': _startUtc,
                      'Date Ended': _endUtc,
                      'Name': DataCardValue1.Text,
                      'Email Address': DataCardValue17_1.Text,
                      'Supervisor Email': DataCardValue17.Text,
                      'Comments': DataCardValue6.Text,
                      'Time Zone': DataCardValue2.Text,
                      'Leave/Overtime': Radio1.Selected.Value
                   }
                )
             )
          )
       )
    )
    There are some small efficiencies that could be added, but first does this produce the result you are after ?
     
    Please ✅ Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful?
    Visit my blog
    Practical Power Apps    LinkedIn  
  • WarrenBelz Profile Picture
    151,135 Most Valuable Professional on at
    Power App Submit Button Error
    A quick follow-up to see if you received the answer you were looking for. Happy to assist further if not.
     
    Please ✅ Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful?
    Visit my blog
    Practical Power Apps    LinkedIn   

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Tom Macfarlan – Community Spotlight

We are honored to recognize Tom Macfarlan as our Community Spotlight for October…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 829 Most Valuable Professional

#2
developerAJ Profile Picture

developerAJ 489

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 395 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics