Hey all,
I am building an app where I'm using 2 column formatted as "People" in SP online list
I need for one of them to set the default value as the manager of the person who is making the request.
I added a form and changed the mode to new.
I set a variable on my OnStart like this : Set(varUserManager,Microsoft365Users.ManagerV2(Microsoft365Users.MyProfileV2().id).displayName])
Then, on my form's DataCardValue I changed the DefaultSelectedItems value to be varUserManager.Value. This shows up just fine, and I'm able to change it if I want, but if I leave it like this after submitting the form the field in SP remains blank...what am I doing wrong?
Solved! Go to Solution.
Hi @Anonymous ,
Here is the code for that:
{
'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims:Concatenate("i:0#.f|membership|",Microsoft365Users.ManagerV2(Microsoft365Users.MyProfileV2().id).Email),
DisplayName:Microsoft365Users.ManagerV2(Microsoft365Users.MyProfileV2().id).displayName,
Email:Microsoft365Users.ManagerV2(Microsoft365Users.MyProfileV2().id).Email
}
I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.
Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.
Hi @Anonymous ,
Try one these 3 methods to set the default value to People picker field:
If(FormMode.New = 1,{
'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims:Concatenate("i:0#.f|membership|",User().Email),
DisplayName:User().FullName,
Email:User().Email
})
OR
If(FormMode.New =1,Microsoft365Users.MyProfile()) // This require Microsoft365Users connector
OR
// Set this on APP OnStart and then use the variable on DefaultSelectedItems propoerty of the field in the form
Set(requesterClaim,{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims:"i:0#.f|membership|" & User().Email,
Department:"",
DisplayName:User().FullName,
Email:User().Email,
JobTitle:"",
Picture:""
});
I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.
Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.
Hello,
It doesn't work as intended, my need is to have the Manager of the person using the app , not the User()
Hi @Anonymous ,
Here is the code for that:
{
'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims:Concatenate("i:0#.f|membership|",Microsoft365Users.ManagerV2(Microsoft365Users.MyProfileV2().id).Email),
DisplayName:Microsoft365Users.ManagerV2(Microsoft365Users.MyProfileV2().id).displayName,
Email:Microsoft365Users.ManagerV2(Microsoft365Users.MyProfileV2().id).Email
}
I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.
Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.
If you are so kind, could you also help me with a code for a image item? On the same data card I want to input the image of the person ( manager in my case) selected in the datacardvalue ...how do I do that?
Hi @Anonymous,
try this to an image:
Microsoft365Users.userPhotoV2(Microsoft365Users.ManagerV2(Microsoft365Users.MyProfileV2().id).id)
I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.
Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.
Hello,
That works for the default value of the datacard. however, if the user changes the person to someone else, the picture does not.
Hi @Anonymous ,
try this:
Microsoft365Users.userPhotoV2(Microsoft365Users.ManagerV2(peoplepickercontrol.Email).id)
I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.
Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.
Hello @KrishnaV ,
It actually doesn't...it doesn't like that I reference the datacard.
I added the SelectedItems but the error is without also.
Besides this, I don't need the manager of the person. That value in datacardvalue10 is already the manager of the user.
Hello Sir , You are Godlike! and saved my life , i dont know How could i thx you enough ...
User | Count |
---|---|
161 | |
86 | |
68 | |
63 | |
62 |
User | Count |
---|---|
212 | |
146 | |
92 | |
81 | |
68 |