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
Prema -Prema - 

how to write apex syntax if i want to check that if related object id is opportunity and if it's not null then update it's any of the field? Please help m trying to check from custom object

Prashant Pandey07Prashant Pandey07
Hi Prema,

I hope you need the related opportunity from the parent..please check the below code and let me know if that works for you.
 
ist<opportunity> opp=new  list<opportunity>();
//I used a dummy cusotm object anf try to retrive its related opportunity 
 Veichle__c vc=[select id,(select id from Opportunities__r) from Veichle__c where id ='a0sf1000006zAgB'];
             system.debug('*****'+vc.Opportunities__r);
//if the opportunity id availabe then add into list to process further
             if(vc.Opportunities__r!=null){
                 opp.add(vc.Opportunities__r);
                 
   }
             system.debug(opp.size());

--
Thanks,
Prashant