0

I've got very simple page:

<apex:page standardController="Employee__c" readOnly="true">

    <apex:pageBlock title="Hello {!$User.FirstName}!">
        You are viewing the {!Employee__c.name} account.
    </apex:pageBlock>
    <apex:detail /> 

</apex:page>

I would like to keep this page read-only. The problem is that on the apex:detail component are buttons like Edit, Delete and Clone. Using them we can modify our fields. I set readOnly=true on page but we still can change values of field by these buttons.

Is there any other way to make whole page readonly? (with buttons?) Or how can i make these buttons disabled?

Thanks for your help.

1

If you remove the "Delete" permission in a user profile's object settings, they will not be able to delete the custom object from any view.

Setup >> Manage Users >> Profiles >> (Profile) >> Object Settings >> (Your custom object) >> Edit >> Uncheck "Delete"

Alternatively, you can also "Override" the delete button with a Visualforce page that has an error message: Setup >> Create >> Objects >> (Your custom object) >> Buttons, Links, & Actions >> Edit the Delete button

Hope this helps

  • Unfortunately I can't do this. The same user will have a choice to open readonly or editable page. So I cant do anything with permission and with overriding a button. But both ideas are interesting so thanks for them. – k4sia Oct 7 '15 at 9:31
0

Did you try setting the inlineEdit attribute to false?

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_detail.htm

  • Yes, no changes. The problem is in these buttons (Edit Delete and Clone). We can still change everything using them – k4sia Oct 5 '15 at 12:39
0

This is your custom page. So you can use Javascript or Jquery to disable the button

 $('#btn_submit').attr('disabled',true);

Pass id or class name. It is a type of hack and in future may be stop working. But for now it will solve your problem.

0

You can use following javascript solution which will remove Edit and Delete button.


$(document).ready(function() {
  $('.btn').each(function(){
         if($(this).attr('title')=='Edit' || $(this).attr('title')=='Delete')
             $(this).remove();
  });
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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