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
starlightstarlight 

how can i edit an existing related list?

I need to edit the Opporutunity product related list.
I need to increase the fields shown from 10 -20.
Is there anyway I can access the code of  existing  related list and change the number of fields shown ?
Or  I need to create my own VF page and added the required functionalities???
 
Ajay K DubediAjay K Dubedi
Hi,
You have to use Opportunity Line Item  to solve your issue.
Let me explain this with example:
Suppose you want to edit Opportunity's related list whose id is "XYZ". Following is the solution:
//Bringing all OLI.
Set<Id> ProductIdSet = [SELECT ProductId from OpportunityLineItem WHERE OpportunityId = 'XYZ'];
//Bring all fields that you require for that product.
List<Product2> prolist = [SELECT Id, Name, ProductCode FROM Product2 WHERE Id IN: ProductIdSet];
Now if you want to edit this, do it in following way:
for(Product2 pr : prolist){
 //Editing for a particular product name
 if(pr.Name == 'SomeName'){
  pr.ProductCode = 'AS147';
 }
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
Deepali KulshresthaDeepali Kulshrestha
Hi,

You can add or remove the fields of the object present in the related list with the help of Page-Layout. If we talk about Opportunity, and you want you to add the fields in the product object present in its related list then you simply need to follow these steps:
1. Go to Setup and then click on Object Manager.
2.  And then go to opportunity and select Page layout for the opportunity.
3.  Now choose the Opportunity Layout and to down to its related List section.
4. Now under Product click on Spanner and you'll find All the available and Selected fields for the related list. 
5. Now you can add or remove 'n' number of fields from your related list.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha.
starlightstarlight
Hi Deepali,
Thanks for the reply.
I have tried this and  we cannot add or remove 'n' number of fields .
Only 10 number of fields are allowed to add.I want to add more fields.any idea on that..
thanks
starlightstarlight
Hi ajay,
Let me try as you suggested.
thanks for the reply
starlightstarlight
Hi ajay,
I have just started learning VF and Apex.
can you please share the detail code if  you have.
it will save a lot of my time.
thanks a  lot