Wednesday, November 07, 2018

Redirection Receiver-Choose a Picture Dependant on Registration Response

Let’s say we wanted to add an image to a User’s profile to quickly identify them as a member of an external customers’ organization. Perhaps you work with multiple vendors and you want to add their logo to the user’s profile. Following the below steps will allow you to add a photo to an external user based on selecting an answer from a drop down list on the registration page.
The first step we need to do if you have not already, is to add the picture column to the Hidden user information list for the site collection in question. We are working in the root site collection, which we suggest all users have access to, so you only have to do this step on the root site collection. If however, you do not allow users access to the root site collection, then this step will need to be repeated on all site collections you want to view a users’ picture on.
Navigate to <sitecollectionurl>/_layouts/15/people.aspx?MembershipGroupId=0. now, you will see 2 new menus.

Click Settings and choose List Settings

Now you will be taken to List Settings page of UIL which was not available with /_catalogs/users/xxxxx.aspx option.

Scroll down and click any view that you want to be modified. In this case, I will chose detail view, then select the “picture” field to be shown in the view.

 Now that the list is set correctly, create a SharePoint document library to hold the pictures. I have named mine VendorImages.
Upload images with correct naming convention “+imagename+” The plus signs must be added to the front and last of the name. See below image for example

Next, we need to create the new entry on the registration form;
Since I want to capture the Vendor name, I will create a “Vendor Name” drop down menu to from which to choose 

Next, Create a registration receiver to build the Picture URL based on registration answer.
Open the web.config file for your desired web application and add your registration receiver in the <registrationReceivers> tag

Below is the text that we used to choose the path based on which answer was given to the Vendor. *NOTE* my images were .png files so this line is looking for the answer (Value) for the Vendor registration field and adding the .png to the file.
<add name="SPPicture" spUserFieldMap="Picture=/VendorImages/+$registrationItem.Fieldanswers.get_Item('Vendor').value+.png" type="SPSolutions.SharePoint.ExCM.ExtranetSPUserRegistrationReceiver, SPSolutions.SharePoint.ExCM, Version=, Culture=neutral, PublicKeyToken=fdcedad4c93ea981" />

Now that the registration receiver is in place, I will register two users with different vendor names

 And browse out to the Hidden User Information List (accessed by navigating to /_catalogs/users/simple.aspx or  /_catalogs/users/detail.aspx) or going out to people and groups.

Now you can see that the correct image was chosen based on which answer was given to the "Vendor" question at registration.

No comments: