Modify read/edit by role

edited February 2017 in Questions
I'd like to find a way to make a few fields read only based on a users role. I've created a model that contains this information via the User object but I'm unsure how to access this information through javascript. 


  • Matt SonesMatt Sones ✭✭
    edited February 2017
  • edited January 2016
    Can you limit editing rights based on the Field Level Security for that role?  Standard SFDC functionality vs javascript?
  • edited January 2016
    Thanks, guys. I was able to do so via bastardized code below. I created a model called 'Running User' and pulled in role. After creating this snippet I modified the 'Field Renderer' field property to 
    'Custom run a Snippet' and input the snippet name. 

    var m = skuid.model.getModel('RunningUser');
    var row = m.getFirstRow(); 
    var fieldToCheck = row.UserRole.Name; 

    var field   = arguments[0],
    $       = skuid.$,
        value   = arguments[1]; 

    // Set the value to be read only if the role is 'Child'
    if (fieldToCheck == 'Child') {
        field.mode = 'readonly'; 
        var renderers = skuid.ui.fieldRenderers; 
        var dt = field.metadata.displaytype; 
        var r = renderers[dt]; 
        if (!r) r = renderers.PICKLIST; 
    } else {
        skuid.ui.fieldRenderers[field.metadata.displaytype][field.mode](field, value);
  • Matt SonesMatt Sones ✭✭
    edited February 2017
    Glad you got it working.

    Unless I'm mistaken, skuid respects your SFDC field level security.
  • edited January 2016
    You're right, Matt.
  • edited January 2016
    The only issue with FLS in this scenario is it's based on profiles or users (via permission sets) not roles. 
Sign In or Register to comment.