function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Venkat Reddy sfdVenkat Reddy sfd 

Unable to make string, the value retrieved from SOQL Query

Hi All,

Please help me, here i am facing one problem, i have retrieved Source_Code__c from my Custom object by descending Order.

I have to trim first five chanrecters and convert that value to number , below SOQL query is working but Iam facing problem with Converting and trimming. could anyone please help me.
List<METADATA_Source__c> Sr=[SELECT id,SOURCE_CODE__c from METADATA_Source__c where SOURCE_CODE__c like 'CGI%' ORDER BY SOURCE_CODE__c DESC ];

     String S= Sr;  // I stucked here
     String S1=S.Substring(5,S.length());
     Integer i= integer.valueOf(S1);
     //Integer j=i+1;

Thanks Advance!!!!
Shashikant SharmaShashikant Sharma
Hi,

Could you please share the error you are getting. As I see your code

String S= Sr this should be chaged to
String S= Sr.get(0).Source_Code__c
As Sr is list of METADATA_Source__c so you can not assign it to String.