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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Help with updating Tex...
Power Apps
Answered

Help with updating Text Labels with Person and Date/Time

(0) ShareShare
ReportReport
Posted on by 1,121

Hi Guys,

 

Below is an App edit page

 

When I click on Yellow Card Sent I want it to put the current user of the app display name as well as update the field in the SharePoint List

 

When I click on the Yellow Reason I want it to put in the current date and time as well as updating the field in the SharePoint List.

 

 

Currently in the OnChange of the button field of Yellow Card Sent I have

 

UpdateContext({var2:User()})

 

And on the Update of the Yellow Issued By I have tried below, but it doesn't like it as it is expecting a record value

 

var2.FullName

 

Username1.JPG

 

Currently for Yellow Reason OnChange I have

 

UpdateContext({var:Now()})

 

On the Yellow Issued Date card I have 

 

var

 

The issue with the date and display name part is that when I click on + to create a new item the date and display name are put in instead of waiting for me to make my changes.

 

John.

 

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @jbrines 

    Get rid of all of the OnChange actions and variables, you don't need them - and they are snapshots - which is why they don't go away when you come back.

     

    Consider the following changes:

    For the User combobox, change the DefaultSelectedItems property to the following (note, you did not mention if the Yellow Card Sent toggle will be changeable in the future, so I assume it is a one-time deal):

    Coalesce(
     Parent.Default,
     If(DataCardValuex.Value,
     { 
     Claims:"i:0#.f|membership|" & Lower(User().Email), 
     Department:"", 
     DisplayName:User().Email, 
     Email:User().Email, 
     JobTitle:".", 
     Picture:"."
     }
     )
    )

    Your Update, and Default properties for the User datacard should remain the default.

     

    For the Yellow Issued Date, set the Default property of the TextInput (or the Text property of the Label) in the Yellow Issued Date datacard to the following:

    Coalesce(Parent.Default,
     If(!IsBlank(DataCardValue-YellowReason.Selected.Value),
     Text(Now(), ShortDateTime)
     )
    )

    You Update, and Default properties of the Yellow Issues Date datacard should remain the default.

     

    I hope this is helpful for you. 

  • jbrines Profile Picture
    1,121 on at

    @RandyHayes 

     

    For the "For the User combobox, change the DefaultSelectedItems property" are you talking the Toggle box property or the datacard property as I cannot see the DefaultSelectedItems property

     

    John

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @jbrines 

    Your User datacard has a combobox control in it:

    RandyHayes_0-1612817598726.png

    I assume that is the one that the Text of your Yellow Issued By label is coming from?

     

    If that is not the case, then my next question would be, what type of columns are the 'Yellow Issued Date' and the 'Yellow Issued By' columns in your list?

     

  • jbrines Profile Picture
    1,121 on at

    @RandyHayes 

     

    I may have caused some confusion with having the user combobox. We are happy to type in the username in to this.

     

    What I am trying to do is

    • When I change Yellow Card Sent to On it adds the name of the person who is using the app to the "Yellow Issued By" and it will also update the SharePoint List column when saved.
    • When I change the Yellow Reason to one of the choices I want it to add the date and time to the "Yellow Date Issued"  and it will also update the SharePoint List column when saved.

     

    I might be double the work but I couldn't figure out a way for both the name and date to be added when I change Yellow Card Sent to On .

     

    Hope this makes better sense?

     

    John.

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @jbrines 

    Thank you for the clarification.  Yes, I was thrown by the User combobox!

     

    So, this is all still easily done, but I didn't get this answered:

    If that is not the case, then my next question would be, what type of columns are the 'Yellow Issued Date' and the 'Yellow Issued By' columns in your list?

     

    And to add to that, how did you add the two fields to your form?  

     

  • jbrines Profile Picture
    1,121 on at

    @RandyHayes 

     

    Yellow Issued Date - Is a Date and Time column

    Yellow Issued By - Is a person column

     

    For the two fields (Yellow Issued Date and Yellow Issued By) I edited the fields that were already there, deleted the date picker and person picker and added in a text label for each.

     

    If it needs changing then I am happy to do so.

     

    John

  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @jbrines 

    Got ya!

     

    This will be easier to do if you get rid of the datacards for the Issued By and then add it back in.  Reason - this will bring back the combobox.  This will be necessary for this to work properly as the Person column is a complex type (i.e. a record).

     

    Now, with that back in place, your solution should be as follows:

    For the Yellow Issued By DataCard:

    1) Set the Default property to the following:

    ThisItem.'Yellow Issued By'

    This should be the default anyway, but just verify.

     

    2) Set the DefaultSelectedItems property of the Combobox in that datacard to the following:

    With({_user:User()},
    Coalesce(Parent.Default,
     If(DataCardValueSent.Value,
     { 
     Claims:"i:0#.f|membership|" & Lower(_user.Email), 
     Department:"", 
     DisplayName:_user.FullName, 
     Email:_user.Email, 
     JobTitle:".", 
     Picture:"."
     }
     )
    )

    This will set the combobox to either the person ALREADY assigned in that column, or, if the Toggle (DataCardValueSent - please replace that control name to match your toggle control name) is true, to the current user.  Otherwise, just blank.

     

    3) Set the Visible property of the Combobox to false

     

    4) Go ahead and add a label into the datacard as you had before and set the Text property to the following:

        DataCardValueBy.Selected.DisplayName 

    Replace the DataCardValueBy with the name of the Combobox control in the datacard.

     

    5) Set the Update property of the data card for this Yellow Issued By field to:

     DataCardValueBy.Selected

    Again, replace the DataCardValueBy with the name of the Combobox control in the datacard.

     

    This should solve the Yellow Issued By label.

     

    For the Yellow Issued Date - use the solution I provided before

    1) Set the Text property of the Label to:

    Text(
     Coalesce(Parent.Default,
     If(!IsBlank(DataCardValueReason.Selected.Value), Now())
     ), 
     ShortDateTime
    )

    Replace the DataCardValueReason with the name of your Reason dropdown control.

     

    2) Set the Update property of the Yellow Issue Date Datacard to:

    DateValue(labelDate)

    Replace labelDate with the name of the control you are displaying the date in.

     

    Hopefully that is pretty straightforward and will be what you are looking for.

  • jbrines Profile Picture
    1,121 on at

    @RandyHayes I get the error below once formula is in.

     

    Screenshot 2021-02-09 213200.JPG

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @jbrines 

    Can you tell me where the red underline is in the error?  I don't see it in the picture.

  • jbrines Profile Picture
    1,121 on at

    @RandyHayes 

     

    The red Underline is under DataCardValueSent.Value

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard