0

I have an object which has a master detail relationship with Account object. I want when creating a new record for this new object from the Account related list, to suggest the current account and not giving the ability to the user to change the record. How can this be applied ? As in the screenshot below, i want the user not to be able to erase this account and select another one. I want it to be the same as in "Edit" action, read only. How can this be achieved? enter image description here

1
  • I dont thinkwe can achieve this when we are creating a new record. We might need a custom solution. Aug 26, 2020 at 9:59

1 Answer 1

1

Solution1 - Change Master detail to Lookup

Just make it readonly for the desired profile from Field level security of the field (You will need to change your master-detail to Lookup)

  1. Goto the child object,
  2. Select the Lookup field (e.g. Account) .
  3. Select the Field level security and then make it read-only for the desired user profile.

Note: The above will work for non System Administrator profiles only, as they have power to unlock readonly fields.

Deleting children

In order to delete the related children, implement a trigger on Account before delete handler.

Solution2 - Create Custom Component

You can create a VF page or Lightning component that will only have Label/display field that will display the account name and then you can drop on the page layout.

6
  • Hi Mahmood and thanks for your answer. However, Salesforce does not let me make the field read only from the Field Level Security. Aug 26, 2020 at 9:52
  • Make sure that the field is not set as Required
    – Mahmood
    Aug 26, 2020 at 9:58
  • Despite the fact that i made it read only, it still gives me the ability to change the parent record. Also, i need it to be a master-detail cause whenever an account is deleted, i want to also make the child records get deleted. Aug 26, 2020 at 10:28
  • Remember that system admins can edit fields that are marked read-only via the page layout.
    – JimG
    Aug 26, 2020 at 11:29
  • Ok, forgot to remove the "Edit read only fields" permission. So with lookup, my problem is solved. What about master-detail relationships? Can this be achieved with master-detail ? Aug 26, 2020 at 12:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .