I had to realize a Custom Field to show when the associated Item has broken role inheritance...

I see 2 ways to do that:

  • Read just in time if the Item has broken role inheritance
  • Derive a Boolean SP Field and keep the value inside of it

I think the first way is more efficent (also because I must not implement an Event Handler on Item Check In or something like that)...

How can I access to the SPListItem from a custom field? Is there any method or suggested practice?

Thank you very much!!

1 Answer 1


The custom field basically uses BaseFieldControl to show field value. This class has two templates for control rendering - DefaultTemplateName (for new/edit form) and DisplayTemplateName (for display form). You can try to create these templates and override Value method of BaseFieldControl. In this method you should have access to the Item property of BaseFieldControl. If the microsoft documentation is correct this property provides SPItem object that has HasUniqueRoleAssignments flag for indicating whether the object has unique role assignments or inherits its role assignments from a parent object.

For example:

public override object Value
        _control = TemplateContainer.FindControl("controlId");
        _control.Visible = Item.HasUniqueRoleAssignments;

        return null;
        base.Value = value;
  • This works with the BaseFieldControl, but I need it during the display in listviewwebpart..
    – Ziba Leah
    Commented Jul 9, 2012 at 14:51
  • it is much easier. Look this post. You can use the same approach.
    – Alexander
    Commented Jul 9, 2012 at 18:38
  • Yes it's the way I follow to create it... But now I have a boolean value and I modify it whenever I modify the permission on the file by 2 custom ribbon actions... I can't face how I can get the item from the SPFieldText that I'm extending without using the BaseFieldControl item
    – Ziba Leah
    Commented Jul 10, 2012 at 9:01
  • 1
    If I understand correctly, in your case the best way is to use class that is inherited from SPFieldBoolean class. This field should be set from code by your custom actions. For this field you can set BaseFieldControl and use _control.Visible = value. if you need to customize list view you can use Glyn post. In your xsl your should check boolean value of this field and show or not labels.
    – Alexander
    Commented Jul 10, 2012 at 10:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.