+ Start a Discussion
Varun AnnadataVarun Annadata 

how to assigin a list to case?

I have created a data case and i am calling that method in my test class.but the problem is i have created a list in my data class and i am assigning list to case object in my test class.So it is giving me illegal assignment from list to case error.how to solve this?
Nagendra Prasad ChNagendra Prasad Ch
Instaed of assigning entire list to Case, assign first record in List to case. Assign List[0] to case.

List<Case> CaseList ;
Case singleCase  = CaseList[0];

If it is not clear, paste your code here, will give exact sintax to ur issue.

Nagendra Prasad.
Amit Chaudhary 8Amit Chaudhary 8
Can you please post your code so that we can help you

If you have list you can try like below

For( Case caseObj : caseList)
   add logic here

If only one record then like below
if(caseList.size() > 0 )
   Case caseObj = caseList[0]