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
Amit Jadhav 22Amit 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;}
}
Best Answer chosen by Amit Jadhav 22
Amit Jadhav 22Amit Jadhav 22
This Is Not A solution

All Answers

Vikash Kumar MandalVikash Kumar Mandal
Hi Amit
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
Amit Jadhav 22Amit Jadhav 22
Error: Illegal assignment from Decimal to List<Decimal> at line 11 column 6
Amit Jadhav 22Amit Jadhav 22
when i change this error shows
Vikash Kumar MandalVikash Kumar Mandal
Change Public List<Decimal> listIex {get;set;} as public Decimal listIex {get;set;}
Amit Jadhav 22Amit Jadhav 22
This Is Not A solution
This was selected as the best answer
Vikash Kumar MandalVikash Kumar Mandal
What error you are getting
 
Amit Jadhav 22Amit Jadhav 22
Error: Illegal assignment from Decimal to List<Decimal> at line 15 column 6
Vikash Kumar MandalVikash Kumar Mandal
Replace public List<Decimal> CFSList {get;set;} as public Decimal CFSList {get;set;} It will work.
Vikash Kumar MandalVikash Kumar Mandal
Have you got a solution.
Ajay K DubediAjay K Dubedi
Hi Amit,
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 
Ajay K DubediAjay K Dubedi
Hi Amit,
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