Sending email with Profile Picture

Post Reply
User avatar
ctearney
Posts: 226
Joined: 21. Feb 2014, 04:14
Location: Dallas, Texas
Contact:

Sending email with Profile Picture

Post by ctearney » 15. Nov 2023, 18:40

We are trying to create a workflow which sends an email to a specific email address/s which includes the profile picture of the user within Service Management. We are running into a challenge of identifying how to reference the profile picture as a variable with the email designer (workflow). Does anyone have a recommendation on this?

If you look at the SPSUserClassBase table there is a data point for the profile called Photo shown but it contains a string that we can not use (see below). You can reference the table DWPFileinfo where you can trace the picture to but you have to use the base64 code for the thumbnail of the picture.

api/filestorage/d7fbbb2e-5c08-bbf0-b128-1b89c1cd7c0e

User avatar
ctearney
Posts: 226
Joined: 21. Feb 2014, 04:14
Location: Dallas, Texas
Contact:

Re: Sending email with Profile Picture

Post by ctearney » 20. Nov 2023, 22:49

“Wanted to provide an update because we figured out a way to embed a user profile photo into a workflow email using a variable.

Summary: The process involves matching the user's expression-objectID from SPSUSerClassBase to a matching value ObjectId from DWPFileInfo. Once that is done, we pull in the Thumbnail from DWPFileInfo which gives us a base64 encoded string that is the photo thumbnail of the users profile photo. Next we take that string and paste it into the source field of an html image tag and then convert the string varible into an html formatted variable that can be placed in the workflow email. Step by step directions below:

1. Drag in a 'Get Single Record Data' action into your workflow from the repository.

2. In that action set data definition to DWPFileInfo.

3. For where expression, set as ObjectId = @ObjectId and under parameters set as followed: Name>ObjectID - Type>GUID - Varible>Set your own variable name that points to expression-objectID of the user that the workflow is running against then hit ok.

4. Now you should be back to where you set the data definition for the action. Under outputs, click add then select asql expression at the top.

5. Enter this asql expression into the box and click validate: CASE WHEN BindAttribute = 'User.Photo' THEN '<img src="' + Thumbnail + '" alt="User Photo">' ELSE NULL END

6. If validation passes, it will allow you to assign the expression to a variable. I created one called strgPhoto.

7. Next add a 'Generate HTML' action to your workflow from the repository.

8. In this action, click the three dots next to output and then point it to strgPhoto. Then for output, create a new variable. I named it htmlPhoto.

9. Next add a 'Send Email' action into your workflow and then insert the htmlPhoto variable in the email designer.

10. Link each action to the workflow starter in the order we created them above and now when the email is sent, you should see the user photo.

Note: If more than one user photo is uploaded from the profile page, this will not work. This is because the asql expression to pull in the photo looks for 'User.Photo' under the BindAttribute from table DWPFileInfo but when there is more than one uploaded through the profile, it has multiple 'User.Photo' entries. “

I have attempted to work around this by having the asql expression check for MAX UpdatedOn value but it does not work even if it validates. I also attempted to name the image file with the users first/last name and then run a asql filter expression to match it to the users name from spsuserclassbase to the file name field called 'name' in dwpfileinfo table but that also does not work, even though it validates. Since those filters did not work, I am manually deleting the older photo from both dwpfileinfo and files tables from the database to get around the duplicate user.photo binding problem.

I know we can also use delete api calls to the filestorage api to acheive the removal of old photos as well but was wondering if anyone had a way to delete these files directly from service management. We will update if we find a way on our end. Thank you!

Post Reply

Return to “Service Desk”

Who is online

Users browsing this forum: No registered users and 0 guests