Filtration question and Cusstom CSS exemple

Hello,

Is It possible in filtration rule to set the department of the curent user ?
Can you provide me an exemple ?

Is it possible in custom css to apply a different color for each different department ?
Can you provide me an exemple ?

Thanks for advance

Hi,
Thank you for your message.

  1. For use department of the current user in the filtration you can try this:
    In “Custom JavaScript” step of the configuration wizard add this code snippet:

renderer.prerenderAction = function(completed){ try { renderer.dataProvider.getBoxGroupItemDataById(_spPageContextInfo.userLoginName, function(dataItem){ window.plCurUserData = dataItem; }); } catch(err) { //handle errors } } finally { completed(); } }
And in “Filtration” step use this code:

function(itemData){
  return window.plCurUserData == null || itemData["WorkEmail"] ==   window.plCurUserData.Properties["WorkEmail"];
}
  1. Please see an example in documentation on this page:
    https://plumsail.com/sharepoint-orgchart/docs/advanced-web-part-configuration/#custom-javascript

Best regards
Evgeniy Kovalev
Plumsail Team

I have try your solution but it doesn’t works.
It does’nt change anything.

For the second point, I try this :

renderer.boxRendered(function(event, box, itemData){
if(itemData[“Department”].contains(‘DIRECTION’)){
box.$elem.css({
‘background-color’ : ‘red’,
‘border-color’: ‘red’

});

}
});

But it doesn’t works

For the first point:
Could you send me your code from “Filtration” step?

For the second point:
I’m sorry for the outdated information in the documentation. Please change"boxRendered" in your code to “onBoxRendered”

Best regards
Evgeniy Kovalev
Plumsail Team

Thanks that works for the second point.

for filtration code :

function(itemData){
return window.plCurUserData == null || itemData[“department”] == window.plCurUserData.Properties[“department”];
}

Hi,
I’m sorry for the delay.
Please, try this code in your Org Chart:
in “Custom JavaScript” step:

[code]
SP.SOD.executeOrDelayUntilScriptLoaded(getUserProperties, ‘SP.UserProfiles.js’);
var userProperties;
function getUserProperties() {

var clientContext = new SP.ClientContext.get_current();
var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);
userProperties = peopleManager.getMyProperties();
clientContext.load(userProperties);
clientContext.executeQueryAsync(onRequestSuccess, onRequestFail);
}

function onRequestSuccess(){
window.userProfileProperties = userProperties.get_userProfileProperties();
}

function onRequestFail(sender, args){
console.log(args.get_message());
}[/code]
And in “Filtration” step:

function(itemData){
  return itemData["Department"] == window.userProfileProperties["Department"];
}

Best regards
Evgeniy Kovalev
Plumsail Team

Hi,

I try your code but the component is now block on loading.
I can’t do anything even modify settings.

Hi,

Do you see any error in Developer Tools Console in your browser (F12)?

Best regards
Evgeniy Kovalev
Plumsail Team

Yes I have this :

Error occurred during processing filtration function.

description “Impossible d’obtenir la propriété « Department » d’une référence null ou non définie”

How can I acces to the settings of the webpart ?
Because it is blocked on loading and settings button is disable.

You may delete and add OrgChart web part and configure it again.

Or right-click on OrgChart web part and choose “Inspect”. In opened Developer Tools find HTML-elements with class “poch-loading-screen” and delete this element. Then, you can use “Settings” button.

Best regards
Evgeniy Kovalev
Plumsail Team