Use custom user profile properties in Filtration?

Hi,

We got a specific query regarding filtration of data based on custom user profile properties.

We want to display the Assistants under the manager (as an Assistant), however we do not want to show the Assistant again (as they report to the manager) in the org chart. We were able to filter this data based on another forum post. However, the filter example shown there works only if the assistants have the job title assistant (which is not true in our case).

We have a custom user profile attribute created (IsAssistant) and that can have a value YES or NO. This will be YES for all assistants in the organization. How do we setup the filter to work based on this custom profile property? I tried the following code but it always returns undefined.

function (itemData, context) {
	if (typeof itemData['IsAssistant'] === "undefined") {
		return (context.itemType == "Assistant" ||
			context.itemType == "Item" &&
			!itemData['Title'].toLocaleLowerCase().contains("assistant"));
	} else {
		return !itemData['IsAssistant'].toLocaleLowerCase().contains("yes");
	}
}

Hi Mohamed,
Thank you for your message.

Please try this code snippet:

function (itemData, context) {
  if(context.itemType == "Item" && itemData['IsAssistant'].toLocaleLowerCase().contains("yes"))
  {
    return false;
  }
  return true;
}

Best regards
Evgeniy Kovalev
Plumsail Team

Nope. Doesn’t work.

On further debugging, I see that itemData[‘IsAssistant’] is undefined.

Also, in itemData, none of the custom user profile properties are available. Apart from IsAssistant we have other columns for employeeID, employeePayrollName, etc. None of these appear.

Also, even if I set these properties to be shown in the Box Template, they are blank and not shown.

Is this a bug or I am missing something?

Can anyone confirm if this is bug?

If no, how do I use the custom user profile properties in the box template or in filtration properties? It shows me the properties but doesn’t show the data when selected.

Your help will be much appreciated.

Hi Mohamed,
sorry for the delay.

I tested the filtration in Org Chart with the custom property of the user profile and it works. A value of the property is not undefined. Please add in “Filtration” step of the configuration wizard this code on top of function:

console.log(itemData);

and find in developer console (F12 in your browser) your object and your custom property.
Could you send the screenshot of your console if you have the undefined value?
If you have sensitive data you can send the screenshot on support@plumsail.com.

Best regards
Evgeniy Kovalev
Plumsail Team

Thank you Evgeniy.

I did a console.log and here are the results (personal information has been modified). It still does not show any of the custom properties in here.

We have the following custom properties created in the user profile service application:

  1. employeeID
  2. employeePayrollName
  3. IsAssistant

[object Object] { [functions]: , AboutMe: "", AccountName: "domain\username", ADGuid: "", Assistant: "", CellPhone: "xxx xxxxxxx", Department: "Department Name", Fax: "", FirstName: "FirstName", HomePhone: "", LastName: "Lastname", Manager: "domain\manager", Office: "Head Office", PersonalSpace: "/personal/username/", PersonalURL: "http://servername:9191/Person.aspx?accountname=domain%5Cusername", PictureURL: "/_layouts/15/userphoto.aspx?size=L&accountname=domain%5Cusername", PreferredName: "FirstName Lastname", PublicSiteRedirect: "", QuickLinks: "", SID: "S-1-5-21-583907252-682003330-53576524-3149", SPS-Birthday: "01/01/1970 00:00:00", SPS-ClaimID: "", SPS-ClaimProviderID: "Windows", SPS-ClaimProviderType: "Windows", SPS-Department: "Department Name", SPS-DisplayOrder: "", SPS-DistinguishedName: "CN=FirstName Lastname,OU=OU_OUNAME,DC=DCNAME,DC=local", SPS-Dotted-line: "", SPS-EmailOptin: "", SPS-FeedIdentifier: "http://servername:9191/personal/username;1.4b5c2593739c405cae09a4bdf2669e85.a3820f25c42a485a953a3b006dba1706.b4c53b936c1e4a7b8ef2fa55bf454ba7.0c37852b34d0418e91c62ac25af4be5b", SPS-HashTags: "", SPS-HireDate: "01/01/2010 00:00:00", SPS-Interests: "", SPS-JobTitle: "MY JobTitle", SPS-Location: "Head Office", SPS-MasterAccountName: "", SPS-MySiteUpgrade: "", SPS-O15FirstRunExperience: "", SPS-ObjectExists: "", SPS-PastProjects: "", SPS-Peers: "", SPS-PersonalSiteCapabilities: "14", SPS-PersonalSiteInstantiationState: "2", SPS-PhoneticDisplayName: "", SPS-PhoneticFirstName: "", SPS-PhoneticLastName: "", SPS-PictureExchangeSyncState: "0", SPS-PicturePlaceholderState: "0", SPS-PictureTimestamp: "63605795814", SPS-PrivacyActivity: "0", SPS-PrivacyPeople: "False", SPS-ProxyAddresses: "", SPS-ResourceAccountName: "", SPS-ResourceSID: "", SPS-Responsibility: "", SPS-SavedAccountName: "domain\username", SPS-SavedSID: "System.Byte[]", SPS-School: "", SPS-SipAddress: "", SPS-Skills: "", SPS-SourceObjectDN: "", SPS-StatusNotes: "", SPS-TimeZone: "", SPS-UserPrincipalName: "username@domain.local", Title: "MY JobTitle", UserName: "username", UserProfile_GUID: "38746d28-020b-4b70-89fa-50f95192652c", WebSite: "", WorkEmail: "username@email.com", WorkPhone: "xx-xxxxxxx" }

Just to add to the previous reply, when i use the SP2013 User Profile Rest API - it does give me all properties of the user, including all custom properties.

servername:9191/_api/sp.userprof … Properties

However, the itemdata does not have these values.

Any idea what could be going wrong here?

Never mind Evgeniy!

We were able to sort this issue out. Unfortunately, when we created the custom user propertied, the Default Privacy Setting was set to Only Me. No wonder the org chart wasn’t able to read the data.

We noticed this issue when we ran the User Profile Rest API and it returned results fine for the logged in user but not other users.

Thanks anyways.