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.
Solved! Go to Solution.
@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
)
)
@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.
@RandyHayes Thanks for the suggestion, but I'm getting the red squiggly line. What did I do something wrong?
@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.
@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
)
)
@RandyHayes Lol, no need to apologize. I tried it and I'm still seeing the red squiggly line. I appreciate your help on this.
@Anonymous
Tell me more about your 'Closed By' column in SharePoint. Is it a single selection or does it allow multiple selections?
@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
)
)
User | Count |
---|---|
125 | |
87 | |
86 | |
75 | |
69 |
User | Count |
---|---|
216 | |
181 | |
140 | |
97 | |
83 |