+ Start a Discussion
sandeep reddy 37sandeep reddy 37 

sub query solution

can any one please tell me how to get child records from parent object 
this the coad 

public class shopcart {
    public list<srinivasreddy__shopcart__c> scart{set;get;}
    public list<srinivasreddy__aproduct__c> apro{set;get;}
    public list<id> ids{set;get;}
    public shopcart(){
       apro=[select srinivasreddy__price__c,Name,(select Name,srinivasreddy__quantity__c,srinivasreddy__total__c from srinivasreddy__shopcart__r)  from srinivasreddy__aproduct__c];
       ids=new list<id>();
        scart=new list<srinivasreddy__shopcart__c>();
    public void addproduct(){
        for(srinivasreddy__aproduct__c c:apro){
          srinivasreddy__shopcart__c sc=new srinivasreddy__shopcart__c();  
        insert scart;
Aniket Malvankar 10Aniket Malvankar 10
Hello Sandeep, 

Did you check on cross object field?

hi sandeep
go to below link for understand how to query parent to child and child to parent in salesforce

i hop it helps you
Thanks :)
and you cannot  contain two consecutive underscore characters in custom fields of custom object (in your case i see srinivasreddy__shopcart__c)
Naveen DhanarajNaveen Dhanaraj
[select srinivasreddy_price__c,Name,(select Name,srinivasreddy_quantity__c,srinivasreddy_total__c from srinivasreddy_shopcart__r)  from srinivasreddy_aproduct__c];
Do you any relationship between two objects..??
sandeep reddy 37sandeep reddy 37
yes srinivasreddy_aproduct__c is master and srinivasreddy_shopcart__r is child object look up relation