function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jo HusseyJo Hussey 

Change Object relationship from Lookup to Master Detail

Hi,

I've been told by a salesforce representative that I need a developer to help solve an issue I have, hence me asking a question on here. 

I want to create a roll up summary on an Account, using the details from their Orders. When I try to create the field as a roll up and then choose the Object to summarise I do not get Orders as an option. I believe I need to change the relationship between these from Lookup to Master detail, but I dont know where to start to look at how to do this. Can anyone advise please?

Screenshot attached showing my current options. Sales Orders is a customized object, it is not one I want to use, the one I want is 'Orders'.

User-added image
VineetKumarVineetKumar
Yes, you need to have a master detail relationship between the objects to have a roll-up.
On Orders object you need to create a Master-Detail relationship field to Account.

Reference :
https://developer.salesforce.com/trailhead/en/data_modeling/object_relationships
Jo HusseyJo Hussey
These fields already have a Lookup relationship. How do I change this?
VineetKumarVineetKumar
  • You can convert a look up to master detail provided if your existing data look ups contain data for all records,
  • Also you should have "Allow reparenting" check box checked for that field otherwise you will find master detail disabled when you try to change the data tyoe to master detail.
To change the relationship, Click Edit on the field, then click on Change Field Type button and select Master-Detail relationship.
Jo HusseyJo Hussey
Where do I find the Allow Reparenting check box?
VineetKumarVineetKumar
You will get it after you have selected the New field type to Master Detail.
Jo HusseyJo Hussey
I dont seem to have the Change Field Type button. can you tell meif I'm in the right place?
User-added image
VineetKumarVineetKumar
Which object are you working on?
Jo HusseyJo Hussey
Orders
VineetKumarVineetKumar
I suppose this is the standard "orders" object also you cannot update the field types for standard fields.
Jo HusseyJo Hussey
I believe it is the standard, yes. If I cannot update the standard field how can I work around this?
VineetKumarVineetKumar
Workaround would be to create a custom logic in Apex to calculate the rollup.
You can refer the below link for code reference :
http://blog.jeffdouglas.com/2009/07/30/roll-up-summary-fields-with-lookup-relationships-part-1/

If you don't want to delve into an Apex code, you can look for process builder as well

Do mark my answer as best answer if it helped solve your problem
Jo HusseyJo Hussey
I've not used Apex. Can you advise about process builder as I've not heard of this.

Thank you for all your help.
Jo HusseyJo Hussey
Is this just for Enterprise? As I'm currently using Professional.
VineetKumarVineetKumar
It is available in the Professional Edition as well
Jo HusseyJo Hussey
Can you please advise how I get to this, as I cannot find it. The link you sent says to start a new flow, but I cannot see how to do this.
VineetKumarVineetKumar
Go to Setup > Create > Workflows & Approvals > Process Builder
Jo HusseyJo Hussey
The link says I need to create a flow before using Process Builder (which I've had a quick look at and the same problem seems to apply, I cannot look at orders from Accounts), but I cannot create a new flow as I dont appear to have the option to.
VineetKumarVineetKumar
Go to Setup > Create > Workflows & Approvals > Flows
It's at the same place
Jo HusseyJo Hussey
I had already found that page and there is no option to create a new flow
VineetKumarVineetKumar
Give below permissions on the profile.
  • Manage Force.com Flow
  • Run Flows 
Jo HusseyJo Hussey
Manage Force.com Flow is ticked, however Run Flows doesnt appear to be something we can change....

User-added image
VineetKumarVineetKumar
Then you should be able to create new flows.
Check this as well :
Available in: both Salesforce Classic and Lightning Experience
Available in: Enterprise, Performance, Unlimited, and Developer Editions
Jo HusseyJo Hussey
I'm using Professional which isnt listed there.