anyone have any idea of how to a one list to an instance of another list ..
public List<WarrantyServices__c> GetResponse(){
if(tnPSResponse != NULL) {
for(tnsPartservicesv13.PartServices ps : tnPSResponse.PartServices.PartServices) {
}
In the above method, I_ws
is an instance of WarrantyServices__c list and i am passing I_ws
instance as an input to the above method . Now my problem is that
i want to add PSlst
to I_ws
which is an instance of warrantyservices list.
Above is my entire class, I want PSlst
to add to I_ws
, meaning when I click on warranty I should get partlist related to that warranty. I have added I_ws
to wrapper class list .
Best Answer
To note:
I_ws
is a single instance ofWarrantyServices__c
DSlst
is alist<Driver__c>
PSlst
is a single instance ofPart_Services__c
Since they are all different types, you can't just create a
list
of all of them together. I suggest creating a subclass that includes all the types you'd like to return.Note: You can always create constructors and instance methods for any subclass you create.
Example:
Update:
Try using this wrapper class instead:
Then in your method(s), have the return type be
TransformOfferSet
, create a newTransformOfferSet
instance in your method, do whatever calculations you need, and then set theTransformOfferSet
variables appropriately.What's great about creating a subclass to hold data is you can use
TransformOfferSet
as both a return type AND an input parameter. Therefore, you can collect/set
all theTransformOfferSet
variable over multiple methods:Brief Example: