Hi guys,
I've done all I could and need some expert advice here. I'm trying to get metadata as well as profile picture of guest users. I need to retrieve the profile picture in an image insert and metadata in a Display Form and Edit Form based on the selected person in the gallery. The gallery's data source comes from a SharePoint list. Everything works fine, except when a guest user is selected.
These guest users are hosted in our Azure AD. I've tried
Office365Users.UserProfileV2(BrowseGallery_EMPLOYEE.Selected.'EMAIL 1').id
AzureAD.GetUser(Unique identifier of a user Ex."user@tenant.onmicrosoft.com or 5f6ce5c7-b521-4842-....).id
So to retrieve the UPN I have constructed the following:
If(
IsBlankOrError(Office365Users.UserProfileV2(BrowseGallery_EMPLOYEE.Selected.'EMAIL 1').id),
Office365Users.UserPhotoV2(
Concatenate(
Left(
BrowseGallery_EMPLOYEE.Selected.'EMAIL 1',
Find(
"@",
BrowseGallery_EMPLOYEE.Selected.'EMAIL 1'
) - 1
),
"_",
Mid(
BrowseGallery_EMPLOYEE.Selected.'EMAIL 1',
Find(
"@",
BrowseGallery_EMPLOYEE.Selected.'EMAIL 1'
) + 1
),
"#EXT#@tenant.onmicrosoft.com"
)
),
Office365Users.UserPhotoV2(BrowseGallery_EMPLOYEE.Selected.'EMAIL 1')
)
the word "tenant" replaced in code "#EXT#"tenant".onmicrosoft.com" for security reasons
The above works perfectly when a tenant user is selected in the gallery. But when I select a guest user in the Gallery it gives me an error even though the the IsBlankOrError returns the Boolean (true/false)
As for the retrieval of the photo for guest users, the UPN does not work (I have tested this by inserting the UPN manually as text) only the Object ID is needed. So if I can use the email address and not the UPN from Azure AD (as I am passing the selected email address from the Gallery or Card) to retrieve the UPN and Object ID my problem would be solved.
Also, the reason for guest users:
We have a multi-brand company with 5 tenants. We built the app in the tenant with the majority employees and added users from other tenants as guest users in order to share the app with them and to get metadata and profile pictures. We also have guest users outside of our 5 tenant environment (service providers, franchisee owners, etc.)
Can anyone please advise on a solution here? Maybe a tenant connector would solve the problem????
Solved! Go to Solution.
Hi @v-xiaochen-msft thanks for the reply. I have worked it out and added some other coding as well. It looks like the same solution you gave. I had to build a couple of if-statements as I need to check between two emails. It get's tricky with guest users but it works.
If(
Or(
Office365Users.UserPhotoMetadata(BrowseGallery_EMPLOYEE.Selected.'EMAIL 1').HasPhoto,
Office365Users.UserPhotoMetadata(
Office365Users.UserProfileV2(
Concatenate(
Left(
BrowseGallery_EMPLOYEE.Selected.'EMAIL 1',
Find(
"@",
BrowseGallery_EMPLOYEE.Selected.'EMAIL 1'
) - 1
),
"_",
Mid(
BrowseGallery_EMPLOYEE.Selected.'EMAIL 1',
Find(
"@",
BrowseGallery_EMPLOYEE.Selected.'EMAIL 1'
) + 1
),
"#EXT#@tenant.onmicrosoft.com"
)
).id
).HasPhoto
),
If(
IsBlankOrError(Office365Users.UserProfileV2(BrowseGallery_EMPLOYEE.Selected.'EMAIL 1').id),
Office365Users.UserPhotoV2(
Office365Users.UserProfileV2(
Concatenate(
Left(
BrowseGallery_EMPLOYEE.Selected.'EMAIL 1',
Find(
"@",
BrowseGallery_EMPLOYEE.Selected.'EMAIL 1'
) - 1
),
"_",
Mid(
BrowseGallery_EMPLOYEE.Selected.'EMAIL 1',
Find(
"@",
BrowseGallery_EMPLOYEE.Selected.'EMAIL 1'
) + 1
),
"#EXT#@tenant.onmicrosoft.com"
)
).id
),
Office365Users.UserPhotoV2(BrowseGallery_EMPLOYEE.Selected.'EMAIL 1')
),
If(
IsBlankOrError(Office365Users.UserProfileV2(BrowseGallery_EMPLOYEE.Selected.'EMAIL 2').id),
Office365Users.UserPhotoV2(
Office365Users.UserProfileV2(
Concatenate(
Left(
BrowseGallery_EMPLOYEE.Selected.'EMAIL 2',
Find(
"@",
BrowseGallery_EMPLOYEE.Selected.'EMAIL 2'
) - 1
),
"_",
Mid(
BrowseGallery_EMPLOYEE.Selected.'EMAIL 2',
Find(
"@",
BrowseGallery_EMPLOYEE.Selected.'EMAIL 2'
) + 1
),
"#EXT#@tenant.onmicrosoft.com"
)
).id
),
Office365Users.UserPhotoV2(BrowseGallery_EMPLOYEE.Selected.'EMAIL 2')
)
)
Hi @ClaudeViret ,
I did a test and validated your idea - Unable to get userPhoto with UPN and Office365User Connector if the user type is guest.
I found a workaround that you could use the real mail to get the guest's photo.
1\ Turn on this setting. It will clear the error on your formula.
2\ Modify your formula
If(
IsBlankOrError(Office365Users.UserProfileV2(BrowseGallery_EMPLOYEE.Selected.'EMAIL 1').id),
Office365Users.UserPhotoV2(
Office365Users.UserProfileV2(
Concatenate(
Left(
BrowseGallery_EMPLOYEE.Selected.'EMAIL 1',
Find(
"@",
BrowseGallery_EMPLOYEE.Selected.'EMAIL 1'
) - 1
),
"_",
Mid(
BrowseGallery_EMPLOYEE.Selected.'EMAIL 1',
Find(
"@",
BrowseGallery_EMPLOYEE.Selected.'EMAIL 1'
) + 1
),
"#EXT#@tenant.onmicrosoft.com"
)
).id
),
Office365Users.UserPhotoV2(BrowseGallery_EMPLOYEE.Selected.'EMAIL 1')
)
Best Regards,
Wearsky
Hi ClaudeViret,
So why you are not using it?
User().Image
For more details read out the link
Let me know if I can provide more details.
Thanks
Regards,
Abdul Wahab
Power Platform/Customer Engagement Developer/Lead/Solution Architecture/Project Manager
Direct/WhatsApp:+923323281237
E-mail: abdulwahabubit@outlook.com
Skype: abdul.wahabubit
Linkedin: https://www.linkedin.com/in/abdul-wahab-a5b8b011a/
Hi @v-xiaochen-msft thanks for the reply. I have worked it out and added some other coding as well. It looks like the same solution you gave. I had to build a couple of if-statements as I need to check between two emails. It get's tricky with guest users but it works.
If(
Or(
Office365Users.UserPhotoMetadata(BrowseGallery_EMPLOYEE.Selected.'EMAIL 1').HasPhoto,
Office365Users.UserPhotoMetadata(
Office365Users.UserProfileV2(
Concatenate(
Left(
BrowseGallery_EMPLOYEE.Selected.'EMAIL 1',
Find(
"@",
BrowseGallery_EMPLOYEE.Selected.'EMAIL 1'
) - 1
),
"_",
Mid(
BrowseGallery_EMPLOYEE.Selected.'EMAIL 1',
Find(
"@",
BrowseGallery_EMPLOYEE.Selected.'EMAIL 1'
) + 1
),
"#EXT#@tenant.onmicrosoft.com"
)
).id
).HasPhoto
),
If(
IsBlankOrError(Office365Users.UserProfileV2(BrowseGallery_EMPLOYEE.Selected.'EMAIL 1').id),
Office365Users.UserPhotoV2(
Office365Users.UserProfileV2(
Concatenate(
Left(
BrowseGallery_EMPLOYEE.Selected.'EMAIL 1',
Find(
"@",
BrowseGallery_EMPLOYEE.Selected.'EMAIL 1'
) - 1
),
"_",
Mid(
BrowseGallery_EMPLOYEE.Selected.'EMAIL 1',
Find(
"@",
BrowseGallery_EMPLOYEE.Selected.'EMAIL 1'
) + 1
),
"#EXT#@tenant.onmicrosoft.com"
)
).id
),
Office365Users.UserPhotoV2(BrowseGallery_EMPLOYEE.Selected.'EMAIL 1')
),
If(
IsBlankOrError(Office365Users.UserProfileV2(BrowseGallery_EMPLOYEE.Selected.'EMAIL 2').id),
Office365Users.UserPhotoV2(
Office365Users.UserProfileV2(
Concatenate(
Left(
BrowseGallery_EMPLOYEE.Selected.'EMAIL 2',
Find(
"@",
BrowseGallery_EMPLOYEE.Selected.'EMAIL 2'
) - 1
),
"_",
Mid(
BrowseGallery_EMPLOYEE.Selected.'EMAIL 2',
Find(
"@",
BrowseGallery_EMPLOYEE.Selected.'EMAIL 2'
) + 1
),
"#EXT#@tenant.onmicrosoft.com"
)
).id
),
Office365Users.UserPhotoV2(BrowseGallery_EMPLOYEE.Selected.'EMAIL 2')
)
)
Hi @AbdulWahab I need the picture of other users and not the current user. The problem I had was to identify the guest users in our Azure AD tenant. I have figured it out thanks.
User | Count |
---|---|
9 | |
3 | |
2 | |
2 | |
1 |
User | Count |
---|---|
14 | |
8 | |
6 | |
3 | |
2 |