+ Start a Discussion
Maddy6161Maddy6161 

I am using standard controller on my vf page for updating the fields, Now on the same page i want to update the Related Lists.

i am using https://c.ap2.visual.force.com/apex/standardpage?id=a0X28000000y4J8 to retrive these field

Object_A i have related object is Object_B
Now want to update the related Object_B fields.
Naresh YadavNaresh Yadav
Hi Maddy6161

Give it a try.
First get the id from url and then query realted object.
String Object_AId = ApexPages.CurrentPage().getParameters().get('id');
List<Object_B__c> listToUpdate = new List<Object_B__c>();
listToUpdate = [SELECT Id, Name, Object_A__c FROM Object_B__c WHERE Object_A__c =: Object_AId];
Now you can update the 'listToUpdate' to update the related Object_B.

Let me know if it help you out.
Peace.

 
Naresh YadavNaresh Yadav
if this helped you out mark it as best asnwer.
Thanks.