+ Start a Discussion
shephalishephali 

Object to string conversion??

Hello friends,
    Here is my code.where i first fetch the max value and using that max value trying to fetch one row.but unable to do so because it needs object to string conversion.
[i tried--->> String s=code.toString(); //not working.]
 AggregateResult[] groupedResults=[select MAX(Agent_ID__c)maxvalue from Mobile_Agent__c];
      Code = groupedResults[0].get('maxvalue');
      TableData=[select Name,Last_Name__c,Device_Phone__c,Subscriber_ID__c,Agent_ID__c,registered_date__c from Mobile_Agent__c where Agent_ID__c='Code'];
Ritesh Gupta 27Ritesh Gupta 27
Hi Shephali,

You can use String.valueof() as shown below
Code = String.valueof(groupedResults[0].get('maxvalue'));

Hope it helps!
dev@brownbeesdev@brownbees
Your query should be like this.
 TableData=[select Name,Last_Name__c,Device_Phone__c,Subscriber_ID__c,Agent_ID__c,registered_date__c from Mobile_Agent__c where Agent_ID__c=:Code];