Think. Build. Salesforce Solutions.

Salesforce Consulting Services across Salesforce Clouds & Across App Lifecycles

Blog

Replacing a master detail field in a Salesforce managed package

By |2022-04-04T13:39:28+00:00April 4th, 2022|

Maintaining an up and running product in Salesforce is a tedious task in itself. There are several upgrades and releases which are required for maintaining and constantly improving a product to keep it up to the market standards.

Now imagine you have a product in a client org and while upgrading the product package, you have the ability to update the contents of the package. But there is this one master detail field that does not get removed from the package. This increases the complexity and you have to ultimately change your architectural approach.

A Master detail field has many powerful attributes, but there also a few limitations attached to it.

  • For a single object, only two Master Detail Salesforce Relationships can be created.
  • The permission on the child record solely depends upon the master record and inherits all the permissions given to the master record.
  • Record Locking – if the child record is getting updated, the master record gets locked and similarly, if the master record is getting updated, the child record gets locked.
  • The master field is required to be included in the page layout of the child record.
  • In the case of custom objects, Sharing rules, Manual sharing, and queues cannot be created on the child object of the master detail relationship.

Due to all the points mentioned above, it is safe to say that some requirements need not be fulfilled through Master detail relationships, which is where the lookup relationships have an upper hand.

Removing a Master detail relationship from a product package is a little different as compared to removing it from a Salesforce org. This includes a 2 step process.

Step 1(Preparing a backup field) – Creation of a Lookup field and storing the data of the master detail field

  • Create a lookup field in your packaging org and update the package to include this field
  • Go ahead and Upgrade the package into the client org. You should be able to see the lookup field as a part of the upgraded package in the Client org
  • Now using a batch class, copy all the record id data present in the Master detail field into the newly created lookup field

Managed Package field in Salesforce

Step 2 – Replacing the Master Detail field in the package

  • Next step is to remove the master detail field from the package. Coming back to the Packaging org, you will be able to see a delete option beside the master detail field.
  • If you try to delete this field, an error will occur showing the various dependencies of the Master detail field in the package code. You need to remove all the references of field present in the package code and replace them with the Lookup field.
  • Now, Even if you have removed the references, the deletion of any field requires the support of Salesforce customer executives to enable component deletion for the package. Raise a case describing the requirement of deleting component in the existing package.
  • Note that the Salesforce support will consider your case if the above-mentioned steps are followed as pre-requisites.
  • Once the deletion has been done, upgrade the package again in the client org.

Verify all the changes again and you will find the solution to be implemented

Salesforce Managed Package Filed

 

Leave A Comment