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
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());
I hope you need the related opportunity from the parent..please check the below code and let me know if that works for you.
--
Thanks,
Prashant