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

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);
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);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.