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 / if statement - hwat di...
Power Apps
Unanswered

if statement - hwat did I do wrong here?

(0) ShareShare
ReportReport
Posted on by 104

Hi all,

 

I am a bit confused...

 

I set the Default of a text input (which is within a data card, hence the Parent.Default) to:

 

If(
cvar_call_now = true,
Text(Now(), "hh:mm");
UpdateContext({cvar_call_now: false}),
Text(Parent.Default, "hh:mm")
)

 

If I have understood everything right so far this should not result in ant problems. It does however generate an error "expected operator" without specifying where it actually wants an operator. I assume the semi-colon after the Text(Now()) is the offender because I added the Update Context just before the error occurred.

 

What's my mistake here? I was under the impression that one could place any number of lines within the result of a condition as long as ";" is used to separate those lines (many posts here on the forum told me so).

 

It is definitely not the fact that I am changing the variable that lead into this branch of the condition (thought that might be the case and just made it update any random variable).

 

TIA for all the good ideas

Hansjoerg

Categories:
  • WarrenBelz Profile Picture
    156,566 Most Valuable Professional on at

    Hi @ha_wai ,

    You cannot use an action in the Default of a control - firstly the Default

    Text(
     If(
     cvar_call_now,
     Now(), 
     Parent.Default
     ), 
     "hh:mm")
    )

    however your logic is a bit baffling on the Variable part - you are saying if c_var_call_now is true set it to false - what conditions need to be present for this to happen?

     

    Please click Accept as solution 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 giving it Thumbs Up.

     

  • ha_wai Profile Picture
    104 on at

    Hi @WarrenBelz ,

     

    thanks for clarifying that. Not nice, but at least helpful.

     

    To answer your background question:

    cvar_call_now is set to true by a button with the intention to register the time the button is pressed. If I don't turn it off after it's been used it will constantly update the value of the text input. Not what I had in mind.

     

    What I am clumsily trying to achieve is a data card with a date/time field that can be edited by either pressing the "now" button or by manually entering a time.  I'm currently struggling a bit with the logic behind it (being not a SW developer at all).

    The general setup is:

    The App is going to record various timepoints in our hospitals patient transfer service (team leaving, arriving at scene etc..)

    EditForm that gets it's data from a Gallery in another screen. Each DataCard to represent one date/time field in a sharepoint list. And each data card to have a big "now" button that the user is supposed to press when a certain event happens. But it should also have an edit function to manually enter a time in case the user didn't press the "now" button at the correct time (the nature of the patient transfer doesn't always allow for timely documentation).

    So far the only solution I could come up with was trying to manipulate the content of the textinput field and then writing it back to the list with Patch().

     

    I am open to any other suggestion, but I am not expecting anybody here to solve my conceptual problems here 🙂

     

    Cheers

    Hansjoerg

  • WarrenBelz Profile Picture
    156,566 Most Valuable Professional on at

    Hi @ha_wai ,

    You can initiate a trigger action on the OnChange of a control, so whatever input changes the "status" could be used to reset the Variable.

     

    Please click Accept as solution 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 giving it Thumbs Up.

     

  • WarrenBelz Profile Picture
    156,566 Most Valuable Professional on at

    Hi @ha_wai ,

    Just checking if you got the result you were looking for on this thread. Happy to help further if not.

    Please click Accept as solution 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 giving it Thumbs Up.

  • ha_wai Profile Picture
    104 on at

    Hi @WarrenBelz ,

     

     apologies for the delay, this project is just a side show to my normal job, hence the irregular attention to it (which doesn't really help either) and thanks heaps for the offer to help.

     

    I think I am currently pursuing a promising approach.

     

    Should this fail I will have to find a way to actually put my problem into a set of questions that can be answered via the Forum. Hope this won't be necessary.

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 397 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 354

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard