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
Rajeswari SankaranRajeswari Sankaran 

i want to check asset account id from my account query ... any idea

Best Answer chosen by Rajeswari Sankaran
Saurabh Gupta ManrasSaurabh Gupta Manras
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 .

All Answers

Saurabh Gupta ManrasSaurabh Gupta Manras
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 .
This was selected as the best answer
Rajeswari SankaranRajeswari Sankaran
Thank you ...