So I am able to return the sobject of a list like so:
//sobjectlist = list of records passed into fuction.
Schema.SObjectType sotype = sobjectList.getsObjectType();
Now this gives me sotype
with stores the actual type of sobject passed in.
I was trying to do the following:
List<sObject> output = (List<sObject>)soType.newInstance();
Which gives me the following error:
Method does not exist or incorrect signature: [Schema.SObjectType].newInstance()
If it's possible, my ultimate goal is to do something like this:
List<SObject> output = (List<SObject>)getSObjectType(sobjectList).newInstance();
But this tosses the following error:
Method does not exist or incorrect signature: getSObjectType(List)
Is there a way to dynamically detect the type of a list and then create a new instance of it in one line? I'm at a loss as to what I am getting wrong....