Filtration question and Cusstom CSS exemple

by clemse31 » Thu Jul 21, 2016 9:29 am

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
clemse31
 
Posts: 6
Joined: Thu Jul 21, 2016 9:26 am

by Evgeniy Kovalev » Thu Jul 21, 2016 2:36 pm

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:
Code: Select all
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:
Code: Select all
function(itemData){
  return window.plCurUserData == null || itemData["WorkEmail"] ==   window.plCurUserData.Properties["WorkEmail"];
}


2. 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
User avatar
Evgeniy Kovalev
 
Posts: 53
Joined: Wed Jul 20, 2016 2:13 pm

by clemse31 » Fri Jul 22, 2016 7:54 am

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
clemse31
 
Posts: 6
Joined: Thu Jul 21, 2016 9:26 am

by Evgeniy Kovalev » Fri Jul 22, 2016 8:48 am

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
User avatar
Evgeniy Kovalev
 
Posts: 53
Joined: Wed Jul 20, 2016 2:13 pm

by clemse31 » Fri Jul 22, 2016 12:13 pm

Thanks that works for the second point.

for filtration code :

function(itemData){
return window.plCurUserData == null || itemData["department"] == window.plCurUserData.Properties["department"];
}
clemse31
 
Posts: 6
Joined: Thu Jul 21, 2016 9:26 am

by Evgeniy Kovalev » Wed Jul 27, 2016 1:05 pm

Hi,
I'm sorry for the delay.
Please, try this code in your Org Chart:
in "Custom JavaScript" step:
Code: Select all
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());
}

And in "Filtration" step:
Code: Select all
function(itemData){
  return itemData["Department"] == window.userProfileProperties["Department"];
}


Best regards
Evgeniy Kovalev
Plumsail Team
User avatar
Evgeniy Kovalev
 
Posts: 53
Joined: Wed Jul 20, 2016 2:13 pm

by clemse31 » Tue Oct 11, 2016 2:40 pm

Hi,

I try your code but the component is now block on loading.
I can't do anything even modify settings.
clemse31
 
Posts: 6
Joined: Thu Jul 21, 2016 9:26 am

by Evgeniy Kovalev » Thu Oct 13, 2016 10:21 am

Hi,

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

Best regards
Evgeniy Kovalev
Plumsail Team
User avatar
Evgeniy Kovalev
 
Posts: 53
Joined: Wed Jul 20, 2016 2:13 pm

by clemse31 » Thu Oct 13, 2016 3:38 pm

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"
clemse31
 
Posts: 6
Joined: Thu Jul 21, 2016 9:26 am

by clemse31 » Thu Oct 13, 2016 3:39 pm

How can I acces to the settings of the webpart ?
Because it is blocked on loading and settings button is disable.
clemse31
 
Posts: 6
Joined: Thu Jul 21, 2016 9:26 am

Next

Return to Org Chart for SharePoint 2013

cron