Export Button rendering/permission

  • 2
  • Question
  • Updated 2 years ago
Hi, i there any way to hide export button on a table from certain profiles?

or any security in profile?

Thx
Photo of Dave

Dave

  • 5,538 Points 5k badge 2x thumb

Posted 3 years ago

  • 2
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
That is not currently possible declaratively. 

I guess you could write some inline javascript that tested the user profile and applied a new CSS class to the table export button with the declaration  "display: hidden;" 

But that seems pretty hackish. 

Another option would be to use rendering conditions on two whole tables.  One with export,  one without.   But I can understand you'd be loathe to do that..  
Photo of Shmuel Kamensky

Shmuel Kamensky, Champion

  • 4,328 Points 4k badge 2x thumb
I did this with permission sets, but then I also had to remove the checkbox column on the table which automatically gets added as the left most column. 

You add a PermissionSetAssignment model with conditions for each of the permission you want to test and a condition for the AssigneeId to match the running user Id attribute (my page uses other permission sets for other rendering conditions). 

Make an inline snippet on load with the following javascript (replace tableId with your actual tableId)

I remove the checkbox column instead of hiding it since I wasn't allowing for any other row level actions (if you only hide it, the left side table border gets hidden as well).

I remove the export button instead of hiding it because I don't want users who are looking for the export button to change the style attribute from display:none to another value which will allow them to add the button back to the page.

$('#tableId').ready(function(){ //name of your permission set var permissionToCheck = 'Export_Allowed__c' //name of your model var permissionMod = skuid.$M('Permissions'); var rows = permissionMod.getRows(); var runningUserAllowed = false; //if there's no row in the permission set model with the Permission set name, the user isn't assigned the permission for(var index in rows){ if(rows[index] && rows[index].PermissionSetId && rows[index].PermissionSet.Name==permissionToCheck){ runningUserAllowed = true; } } //remove check boxes in any case $("#tableId").find("[class*='rowselect']").closest('th,td').remove(); //if the user doens't have the permission set assigned to them, hide the export. if(!runningUserAllowed){ $("#tableId").find(".nx-export-btn").remove(); } });


Make sure your Permissions model is before the model of the table you are loading.

@Rob, you're right this is hackish. If Skuid decides to change the CSS class name of the export button, this would have to be updated, and if the table gets re-rendered, this javascript would have to be run again. 

I added an idea for this

https://community.skuid.com/skuid/topics/conditional-rendering-of-the-table-export-button
(Edited)
Photo of Shmuel Kamensky

Shmuel Kamensky, Champion

  • 4,328 Points 4k badge 2x thumb
Rob you're right it's hackish. Too hakish. When I sorted on the columns, the entire table re-rendered. To use javascript for this I'd have had to watch for table changes which is too complex given the easy alternative. I used your second option and it worked fine. Trouble is I'll have to make sure to keep the two tables in sync each time I update it.