You need to sign in to do that
Don't have an account?
Add data to Generic List with multiple sobject List's
Hi I have some 9 sobjects data retrieved via SOQL. Now I want to add all this List's to a Generic List<sobejct> type to perform single DML operation
Can't this be done with out using For-loops ?
I tried addALL method od list
Can't this be done with out using For-loops ?
I tried addALL method od list
All Answers
the above code is helpful for me but can you tell me how to retrive data from this sobject like as below
for(sobject acc:objects)
{
for(Account t:acc[0].account)
{
system.debug('....name...'+t.name);
}
}
its not working can you suggest me how to fetch the data from the sobject by using forloop
Iterate through your generic sobject list and use instance of to find sobject type, and add it to your list of sobject.
1) i have one text field name NEWONE on contact standard object in which i have to put three id records of contacts
2) now i have to put that records in a list using slpit method and add in the list
how i can do that pls tell me ?
But be warned, if the field is empty this will throw a NPE so you'll want to make sure it's not null before you try to do that.
How to make an apex class as generic .
@AuraEnabled
public static list<Task> getContactTask(id recordId){
system.debug('>>>>Record Id>>>>>'+recordId);
list<Application__c> appList=[select id,Contact__c from Application__c where id=:recordId];
list<Contact> cons=new list<Contact>();
if (!appList.isEmpty()){
list<Task> tsk=[select id,Subject,Priority,ActivityDate,Due_Date__c,
whoId from task where whoId=:appList[0].Contact__c];
return tsk;
}
return null;
},
As I tried using but how to pass task who id .