Skip to main content

Help with as Apex Code Error: 

 

Hi  Trailblazers, 

 

I am getting below error for the code , request help if fixing the same 

 

Help with as Apex Code Error : Expression must be a List type

 

Screenshot of Lime 21.jpg

 

 

public class bookMyShowClass {

public static void createBookMyShowClass(string Type) {

String recordTypeId;

if (Type == 'Movie') {

recordTypeId = '0125h000000qHyDAAU';

}

else if(Type == 'Drama'){

recordTypeId = '0125h000000qHyIAAU';

}

else if (Type == 'Documentary') {

recordTypeId = '0125h000000qHyNAAU';

}

List<Contact> conList =[SELECT Id from Contact WHERE Name ='Raju Hari' LIMIT 1];

Book_My_Show__c bookMyShow = new Book_My_Show__c();

bookMyShow.Customer__c = bookMyShow[0].Id;

bookMyShow.Amount__c = 100;

bookMyShow.Rating__c = 'Hot';

bookMyShow.RecordTypeId = recordTypeId;

insert bookMyShow;

}

}

4 个回答
  1. 2022年10月31日 23:36

    Hi @Amit Gomes ,

     

    Please change the following part

     

    bookMyShow.Customer__c  =   bookMyShow[0].Id;

     

    -->

     

    bookMyShow.Customer__c  =   conList[0].Id;

0/9000