You need to sign in to do that
Don't have an account?
Amit Jadhav 22
error:List has more than 1 row for assignment to SObject
Controller:
public with sharing class costsheet {
public String OrderId;
public Order ord;
public Shipper_Info_India__c SII;
public costsheet(ApexPages.StandardController controller) {
ord= (Order)Controller.getRecord();
system.debug('ORD--'+ord);
OrderId=Apexpages.currentpage().getParameters().get('id');
listIex =[Select Id,subtotal__c from Shipper_Info_India__c where Supplier_Order__r.id =:ord.id AND RecordType.Name='Steamer Charges'].subtotal__c ;
/*if(SII.Bill_Type__c =='Service Type'){
CHAList =[Select Id,subtotal__c from Shipper_Info_India__c where Supplier_Order__r.id =:ord.id AND RecordType.Name='CHA Charges' ].subtotal__c ;
}*/
CFSList =[Select Id,subtotal__c from Shipper_Info_India__c where Supplier_Order__r.id =:ord.id AND RecordType.Name='CFS Charges' ].subtotal__c ;
//fetchlist();
Calculation();
}
public Decimal CFSList {get;set;}
public Decimal CHAList {get;set;}
Public Decimal listIex {get;set;}
}
public with sharing class costsheet {
public String OrderId;
public Order ord;
public Shipper_Info_India__c SII;
public costsheet(ApexPages.StandardController controller) {
ord= (Order)Controller.getRecord();
system.debug('ORD--'+ord);
OrderId=Apexpages.currentpage().getParameters().get('id');
listIex =[Select Id,subtotal__c from Shipper_Info_India__c where Supplier_Order__r.id =:ord.id AND RecordType.Name='Steamer Charges'].subtotal__c ;
/*if(SII.Bill_Type__c =='Service Type'){
CHAList =[Select Id,subtotal__c from Shipper_Info_India__c where Supplier_Order__r.id =:ord.id AND RecordType.Name='CHA Charges' ].subtotal__c ;
}*/
CFSList =[Select Id,subtotal__c from Shipper_Info_India__c where Supplier_Order__r.id =:ord.id AND RecordType.Name='CFS Charges' ].subtotal__c ;
//fetchlist();
Calculation();
}
public Decimal CFSList {get;set;}
public Decimal CHAList {get;set;}
Public Decimal listIex {get;set;}
}
All Answers
You have Written
public Decimal CFSList {get;set;}
public Decimal CHAList {get;set;}
Public Decimal listIex {get;set;}
which store only one value but it is getting more than one value in SOQL.
Replace the variable declaration with a List like below
public List<Decimal> CFSList {get;set;}
public List<Decimal> CHAList {get;set;}
Public List<Decimal> listIex {get;set;}
Mark as best answer if problem solved.
Thanks!
Vikash
Try replacing your code: (this part only)
public Decimal CFSList {get;set;}
public Decimal CHAList {get;set;}
Public Decimal listIex {get;set;}
With this:
public List<Decimal> CFSList {get;set;}
public List<Decimal> CHAList {get;set;}
Public List<Decimal> listIex {get;set;}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
Got your problem,
Now try the following:
First replace:
public Decimal CFSList {get;set;}
public Decimal CHAList {get;set;}
Public Decimal listIex {get;set;}
With this:
public List<Decimal> CFSList {get;set;}
public List<Decimal> CHAList {get;set;}
Public List<Decimal> listIex {get;set;}
And then instead of:
listIex =[Select Id,subtotal__c from Shipper_Info_India__c where Supplier_Order__r.id =:ord.id AND RecordType.Name='Steamer Charges'].subtotal__c ;
Try : listIex.add([Select Id,subtotal__c from Shipper_Info_India__c where Supplier_Order__r.id =:ord.id AND RecordType.Name='Steamer Charges'].subtotal__c);
Do similar for rest of lists. Hope it now helps. Please update me if any further assistance is required.
Thanks,
Ajay Dubedi