0

I would want the record to not to redirect to the "Edit Page" when clicked on "Edit Link" instead want to "Alert" the user with a warning message.

Basically, I am to lock a record when "the stage in Opportunity is Closed". For which I am creating a "custom button" which is of "JavaScript" and redirecting to "Edit Page" when the "Stage holds other values". This works fine when the user clicks on the "edit button" in the detail page.

However, when it comes to the "Edit link" in the "Account related list", I am unable to control the user to not to enter the "Edit page".

By the way, I am supposed to do this only in the standard way (no controllers)

3

You can override the edit link completely so that whereever it is used, your code is used instead.

  • Go to Setup > Customize > Opportunities > Buttons, Links and Actions
  • Click "Edit" next to the Edit link
  • select a VisualForce page

To use this method, you will have to create a VisualForce page using the Opportunity standard controller. You shouldn't need any custom controller. You can code your JavaScript into this VF page.

It won't be exactly the same experience for your users because the browser will navigate to your new page, popup the alert, and either navigate straight back to where they came from, or navigate forward to the Edit page.

To enable navigating forward to the edit page you need to tell SFDC to not use the override this time, by adding this parameter to the URL:

nooverride=1

There are other ways to achieve a similar effect:

You could have a "Closed Opportunity" record type, with a page layout where all the fields are Read-Only. If you add a workflow to switch the opportunity to the "Closed.." type when it is closed (and switch it back if it is re-opened?) then users will not be able to edit the opportunity when it is closed. (Unless they have the Edit Read Only Fields permission - handy for admins).

You could add a validation rule that checks for the opportunity stage, and a long list of fields that you are checking for ISCHANGED.

0

You can use the trigger to stop the user making changes to record when it meets your criteria . I done have any knowledge in stoping the user from entering the edit page.

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.