cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Auto populate user name only for Closed status

Greetings.

 

I have a SharePoint list that I'm using as a leads database and I'm having a small issue that I cannot figure out. When a rep selects "Closed" from the status dropdown, it autofills the closed date and closed by fields based on who's logged in. I'm using the following code to accomplish that.

 

If(DataCardValue13.Selected.Value="Closed"
,{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims:Concatenate("i:0#.f|membership|",Office365Users.UserProfile(User().Email).Mail),
DisplayName:Office365Users.UserProfile(User().Email).DisplayName,
Email:Office365Users.UserProfile(User().Email).Mail},ThisItem.'Closed By')

 

When I started testing the form, I noticed that when I made a change to a list items, it wouldn't save back to SharePoint. I found a blog post (don't remember where) that suggested to add the following code in the Update property for the DataCard.

 

{Claims:"i:0#.f|membership|" & User().Email,Department:"",DisplayName:"",Email:"",JobTitle:"",Picture:""}

 

The problem of saving changes to a list item was fixed by adding the code above, but now I noticed that when I select "In Progress" from the status dropdown, it saves the users name in the Closed By field. How can that be fixed?

 

Any help would be greatly appreciated.

 

Screenshot 2021-01-28 074533.pngScreenshot 2021-01-28 074537.pngScreenshot 2021-01-28 074515.png

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@Anonymous 

Ugh!!! I'm batting a zero today!  I've got so many irons in the fire going on that I'm not getting good focus - I apologize for that.

I originally gave you a formula to account for that and copied the wrong formula from a previous post and changed it.

Then I found that I had done that and lastly gave you a correct, but neglected to put in the part that fixed that issue.

SO...here we go again...The formula below *should* be the nail in the box.  What I was missing was the IsBlank part for the Parent.Default.  It is in this formula for the DefaultSelectedItems:

With({_user:User()},
    If(DataCardValue13.Selected.Value="Closed" && IsBlank(Parent.Default),
        {Claims: "i:0#.f|membership|" & Lower(_user.Email),
         Department:"", 
         DisplayName: _user.Email, 
         Email:_user.Email, 
         JobTitle:".", 
         Picture:"."
        },
        Parent.Default
    )
)

 

_____________________________________________________________________________________
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

43 REPLIES 43
RandyHayes
Super User
Super User

@Anonymous 

Please consider changing the Update property Formula of the DataCard for 'Closed By' to the following:

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

You don't need the odata type to be specified any longer and you only need to supply emails to the record columns of claims, displayname and email.  SharePoint ignores all the rest and will automatically fill in the everything from its internal user management system.

 

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!
Anonymous
Not applicable

@RandyHayes Thanks for the suggestion, but I'm getting the red squiggly line. What did I do something wrong?

RandyHayes
Super User
Super User

@Anonymous 

Can you let me know what the error is?  Hover over the formula and see what it shows as the error.

Perhaps also provide a screenshot.

_____________________________________________________________________________________
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!
Anonymous
Not applicable

@RandyHayes I guess that would have helped (duh, sorry about that). See image below.

 

Screenshot 2021-01-28 100503.png

RandyHayes
Super User
Super User

@Anonymous 

Subtle little typos!!  Sorry, I type these things freehand, so the formula editor is not there to my rescue to point out errors easily.

 

The formula should be this:

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

 

_____________________________________________________________________________________
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!
Anonymous
Not applicable

@RandyHayes Lol, no need to apologize. I tried it and I'm still seeing the red squiggly line. I appreciate your help on this.

 

Screenshot 2021-01-28 103804.png

RandyHayes
Super User
Super User

@Anonymous 

Tell me more about your 'Closed By' column in SharePoint.  Is it a single selection or does it allow multiple selections?

_____________________________________________________________________________________
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!
Anonymous
Not applicable

@RandyHayes Sure. It's a people picker.

Screenshot 2021-01-28 104647.png

RandyHayes
Super User
Super User

@Anonymous 

Perfect!

And again...without the formula editor at hand (I wish the forum would have some simulator), I see another flaw in what I provided.

Let's go with this one:

With({_user:User()},
    If(DataCardValue13.Selected.Value="Closed",
        {Claims: "i:0#.f|membership|" & Lower(_user.Email),
         Department:"", 
         DisplayName: _user.Email, 
         Email:_user.Email, 
         JobTitle:".", 
         Picture:"."
        },
        Self.Default
    )
)
_____________________________________________________________________________________
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 Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

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