You need to sign in to do that
Don't have an account?

AggregateResult
Hi,
this is code in php
function get_car_manufacturer()
{
$data['car_manufac'] = $this->cardata_model->get_car_manufacturer();
for($i=0; $i<count($data['car_manufac']); $i++){
$fin_data[] = array(
'value'=>$data['car_manufac'][$i]['manufacturer'],
'label'=>$data['car_manufac'][$i]['manufacturer']
);
}
echo json_encode($fin_data);
}
function get_model()
{
$data['car_model'] = $this->cardata_model->get_car_model($_POST['manu']);
for($i=0; $i<count($data['car_model']); $i++){
$fin_data[] = array(
'value'=>$data['car_model'][$i]['model'],
'label'=>$data['car_model'][$i]['model']
);
}
$_SESSION['car_models'] = json_encode($fin_data);
echo json_encode($fin_data);
}
public function get_variant()
{
$data['car_variant'] = $this->cardata_model->get_car_variant($_POST['model']);
for($i=0; $i<count($data['car_variant']); $i++){
$fin_data[] = array(
'value'=>$data['car_variant'][$i]['model_type'].'@@'.$data['car_variant'][$i]['fuel_type'],
'label'=>$data['car_variant'][$i]['model_type'].' '.$data['car_variant'][$i]['fuel_type']
);
}
$_SESSION['car_variant'] = json_encode($fin_data);
echo json_encode($fin_data);
}
------------------this is apex class---
global with sharing class ExchangeRemoter{
public static list<jud_old_cars__c> oldCars{get; set;}
public ExchangeRemoter(){
}
@RemoteAction
global static Map<String, String> get_car_manufacturer(){
//Set<Id> makersId = new Set<Id>();
//Set<jud_old_cars__c> retCars = new list<jud_old_cars__c>();
List<Map<String,String>> oldCarList = new List<Map<String,String>>();
list<jud_old_cars__c> oldCars = [Select manufacturer__c from jud_old_cars__c group by manufacturer__c];
for(jud_old_cars__c manu : oldCars){
//AggregateResult manus = [select manufacturer__c FROM jud_old_cars__c GROUP BY manufacturer__c];
oldCarList.add(new Map<String, String> {
'value'=>manu.manufacturer__c,
'label'=>manu.manufacturer__c
});
}
return oldCarList;
}
}
i'm getting error this . i have create object and field ..i want to create a class and give remote .please help me out friends
Illegal assignment from List<AggregateResult> to List<jud_old_cars__c>
Illegal conversion from List<Map<String,String>> to Map<String,String>
this is code in php
function get_car_manufacturer()
{
$data['car_manufac'] = $this->cardata_model->get_car_manufacturer();
for($i=0; $i<count($data['car_manufac']); $i++){
$fin_data[] = array(
'value'=>$data['car_manufac'][$i]['manufacturer'],
'label'=>$data['car_manufac'][$i]['manufacturer']
);
}
echo json_encode($fin_data);
}
function get_model()
{
$data['car_model'] = $this->cardata_model->get_car_model($_POST['manu']);
for($i=0; $i<count($data['car_model']); $i++){
$fin_data[] = array(
'value'=>$data['car_model'][$i]['model'],
'label'=>$data['car_model'][$i]['model']
);
}
$_SESSION['car_models'] = json_encode($fin_data);
echo json_encode($fin_data);
}
public function get_variant()
{
$data['car_variant'] = $this->cardata_model->get_car_variant($_POST['model']);
for($i=0; $i<count($data['car_variant']); $i++){
$fin_data[] = array(
'value'=>$data['car_variant'][$i]['model_type'].'@@'.$data['car_variant'][$i]['fuel_type'],
'label'=>$data['car_variant'][$i]['model_type'].' '.$data['car_variant'][$i]['fuel_type']
);
}
$_SESSION['car_variant'] = json_encode($fin_data);
echo json_encode($fin_data);
}
------------------this is apex class---
global with sharing class ExchangeRemoter{
public static list<jud_old_cars__c> oldCars{get; set;}
public ExchangeRemoter(){
}
@RemoteAction
global static Map<String, String> get_car_manufacturer(){
//Set<Id> makersId = new Set<Id>();
//Set<jud_old_cars__c> retCars = new list<jud_old_cars__c>();
List<Map<String,String>> oldCarList = new List<Map<String,String>>();
list<jud_old_cars__c> oldCars = [Select manufacturer__c from jud_old_cars__c group by manufacturer__c];
for(jud_old_cars__c manu : oldCars){
//AggregateResult manus = [select manufacturer__c FROM jud_old_cars__c GROUP BY manufacturer__c];
oldCarList.add(new Map<String, String> {
'value'=>manu.manufacturer__c,
'label'=>manu.manufacturer__c
});
}
return oldCarList;
}
}
i'm getting error this . i have create object and field ..i want to create a class and give remote .please help me out friends
Illegal assignment from List<AggregateResult> to List<jud_old_cars__c>
Illegal conversion from List<Map<String,String>> to Map<String,String>
Hi Vishal,
You are returning List<Map<String,String>> to Map<String,String>
If you change your method with this below code then it will work fine.
OR if you want to return like this
then you have to change some code.
Hope it will help you.
Please mark as a best if It helps you.
Regards,
Suraj
it's not wofking .i'm getting error
Unknown method 'ExchangeRemoter.show()'
Illegal assignment from List<AggregateResult> to List<jud_old_cars__c>
Illegal conversion from List<Map<String,String>> to Map<String,String>
help me out
Hi vishal,
Your given code there is no show() method
problem is occuring in your show() method please check have you created this or not.
this is my compleet code
global with sharing class ExchangeRemoter{
public static list<jud_old_cars__c> oldCars{get; set;}
public ExchangeRemoter(){
}
@RemoteAction
global static List<Map<String,String>> get_car_manufacturer(){
//Set<Id> makersId = new Set<Id>();
//Set<jud_old_cars__c> retCars = new list<jud_old_cars__c>();
List<Map<String,String>> oldCarList = new List<Map<String,String>>();
AggregateResult manus = [select manufacturer__c FROM jud_old_cars__c GROUP BY manufacturer__c];
list<jud_old_cars__c> oldCars = [Select manufacturer__c from jud_old_cars__c group by manufacturer__c];
for(jud_old_cars__c manu : oldCars){
oldCarList.add(new Map<String, String> {
'value'=>manu.manufacturer__c,
'label'=>manu.manufacturer__c
});
}
return oldCarList;
}
}
-----------------------------------
i'm getting two error.
Unknown method 'ExchangeRemoter.show()'
Illegal assignment from List<AggregateResult> to List<jud_old_cars__c>
not getting how to do?
pls help me out asap
Will return List<AggregateResult> - because you have a "Group By" clause in your query.
You cannot therefore put it into a List<jud_old_cars__c> as this is different.
You must put it into a List<AggregateResult>
Then in your loop / future code etc. you will have to GET the AggregateResult row from your results and process it accordingly with the methods available as per the docs here:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_SOQL_agg_fns.htm
still i'm getting another two error .pls help me out friends.
error is
Unknown method 'ExchangeRemoter.show()'
Invalid loop variable type expected AggregateResult was jud_old_cars__c
I would have a look about for where you are invoking this method from and post another question perhaps to work out what that is doing.
Regarding the invalid loop variable, you can't just change the definition of "oldcars" - you will need to change the type of the for loop assignment, and read the documentation I linked to on AggregateFunctions
Here's the next line...
bear in mind, manu is now NOT a jud_old_cars__c it is an AggregateResult object! ;)