cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jbrines
Post Prodigy
Post Prodigy

Help with updating Text Labels with Person and Date/Time

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.

 

4 ACCEPTED SOLUTIONS

Accepted Solutions
RandyHayes
Super User
Super User

@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.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

RandyHayes
Super User
Super User

@jbrines 

You will need to use the Office365 Connector in order to get the manager information.

However, if you are already planning to do this in a Flow, why not just grab those values in the Flow and send accordingly?  You could certainly do it in your app, but it would involve that connector and you would then need to store this in your list item.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

RandyHayes
Super User
Super User

@jbrines 

So, this stems back to a mistake I made in message #20.  Your Update property should be DateTimeValue not DateValue.  DateValue returns just the date portion of the text, DateTimeValue will include the time as well.

Sorry I didn't catch that a while ago.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

RandyHayes
Super User
Super User

@jbrines 

argg...you keep changing control types and field types on me!!! 🤣🤣🤣😂

If you're going to use a dropdown, then it is a whole lot different than a toggle.

First off, I would assume that your datacard (when you added it), because the underlying column is now a Choice column, it showed up as a datacard with a dropdown in it already.  So, there is NOTHING that you have to change for the datacard for that control/column.

For your other formula, you need to make that a formula for a dropdown, so, replace DataCardValue11.Value with DataCardValue11.Selected.Value = "Yes"

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

45 REPLIES 45
RandyHayes
Super User
Super User

@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. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@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
Super User
Super User

@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?

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@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
Super User
Super User

@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?  

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@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

RandyHayes
Super User
Super User

@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.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

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

 

Screenshot 2021-02-09 213200.JPG

RandyHayes
Super User
Super User

@jbrines 

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

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (3,732)