1

while executing this code,am getting this error: Method does not exist or incorrect signature: void substring(Integer, Integer) from the type List<MVImportBatch__c>

code:

 List<MVImportBatch__c> record = new List<MVImportBatch__c>();
record =[SELECT Id FROM MVImportBatch__c limit 1];
Integer cid;
cid= record.substring(0,3);
system.debug('cid:'+cid);

error:

Method does not exist or incorrect signature: void substring(Integer, Integer) from the type List

2 Answers 2

1

you want to get first 3 symbols of record id?

MVImportBatch__c record = [
    select Id 
    from MVImportBatch__c
    limit 1
];
String cid = String.valueOf(record.Id).substring(0,3);
System.debug('cid:'+cid);
0
1

substring() is of String type and not of List type. Replace line 4 with this:

   String cid= String.valueOf(record.Id).substring(0,3);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .