Hi guys,
I have this snipet that works wonderfuly. Thank again @NoelDillan09931 !! It was my first code adaptation 2 months ago.
/Show edit button if loggedin user is “Responsable of Idea”/
$(document).on(‘knack-view-render.view_265’, function(event, view, data) {
$(’#view_265 div.kn-details-link’).hide();
var LoggedInUser = (Knack.getUserAttributes().name);
var Responsable = $(’#view_265 div.kn-detail.field_271 > div.kn-detail-body’).text();
if(LoggedInUser === Responsable) {
$(’#view_265 div.kn-details-link’).show();
};
});
I am streamlining this scene, and I want also to Show edit button if the loggedin user contains Coordinador role.
Investigating I found parts of the solution but cannot make it work.
Knack.getUserRoles(); // [‘object_1’, ‘object_2’]
Knack.getUserRoles(‘object_1’); // true
if (var1 == x || var2 == y)
I reached this stage:
/Show edit button if loggedin user “is Responsable of Idea” OR “contains Coordinador Role”/
$(document).on(‘knack-view-render.view_265’, function(event, view, data) {
$(’#view_265 div.kn-details-link’).hide();
var LoggedInUser = (Knack.getUserAttributes().name);
var Responsable = $(’#view_265 div.kn-detail.field_271 > div.kn-detail-body’).text();
var LoggedInRole = (Knack.getUserRoles());
if(LoggedInUser === Responsable || LoggedInRole == Coordinador) {
$(’#view_265 div.kn-details-link’).show();
};
});
Not bad where I arrived but missing something.
That helps me to not duplicate a whole highly detailed view just for 1 field. Ok, I can create a view with just this only field and Page Rules, and that would be the alternative if I don’t succeed with this JS code.