Hello bro, please refer to below code surely you will get what you want .
for(Account acc : [SELECT id,(SELECT id,Name,accountid FROM Assets) FROM account]){ // For parent-child soql System.debug('account-'+ acc.id); for( asset asobj : acc.Assets){ System.debug('asset-'+asobj.Name); System.debug('asset-'+asobj.accountid ); // here you have ur asset accountid
} }
Please choose it as the Best answer, if you find it helpful .
Hello bro, please refer to below code surely you will get what you want .
for(Account acc : [SELECT id,(SELECT id,Name,accountid FROM Assets) FROM account]){ // For parent-child soql System.debug('account-'+ acc.id); for( asset asobj : acc.Assets){ System.debug('asset-'+asobj.Name); System.debug('asset-'+asobj.accountid ); // here you have ur asset accountid
} }
Please choose it as the Best answer, if you find it helpful .
for(Account acc : [SELECT id,(SELECT id,Name,accountid FROM Assets) FROM account]){ // For parent-child soql
System.debug('account-'+ acc.id);
for( asset asobj : acc.Assets){
System.debug('asset-'+asobj.Name);
System.debug('asset-'+asobj.accountid ); // here you have ur asset accountid
}
}
Please choose it as the Best answer, if you find it helpful .
All Answers
for(Account acc : [SELECT id,(SELECT id,Name,accountid FROM Assets) FROM account]){ // For parent-child soql
System.debug('account-'+ acc.id);
for( asset asobj : acc.Assets){
System.debug('asset-'+asobj.Name);
System.debug('asset-'+asobj.accountid ); // here you have ur asset accountid
}
}
Please choose it as the Best answer, if you find it helpful .