Skip to main content
Notice removed Content dispute by CommunityBot
Post Unlocked by CommunityBot
Post Locked by Adrian Larson
Notice added Content dispute by Adrian Larson
Rollback to Revision 6
Source Link
Adrian Larson
  • 151.4k
  • 38
  • 247
  • 431

Not able to update custom field from Apex Class, getting Illegal assignment from List<AggregateResult> to List<Rating_Request__c>

Not able to update custom field from Apex class, getting below error:

Illegal assignment from List to List<Rating_Request__c>

Can anyone help where I am doing wrong. If possible provide sample code.

Below is my code :

public void updateflgusertb(string Selected)
{
    
    List<Rating_Request__c> usr = [SELECT ID,Question__c,Order_Sequence__c,User_Ratings__c FROM                     
        Rating_Request__c where User__c=:UserInfo.getUserId() and User_Rating__c = 0 
        group by                           
        ID,Question__c,Order_Sequence__c,User_Ratings__c 
        order by Order_Sequence__c  LIMIT 1];
    List<Rating_Request__c> rateupdate = new List<Rating_Request__c>();  
    for(Rating_Request__c objrating : usr)
    {
        objrating.User_Ratings__c = Selected;
        rateupdate.add(objrating);
    }
    update(rateupdate);
    
}

Thanks in advance

Not able to update custom field from Apex Class, getting Illegal assignment

Not able to update custom field from Apex class, getting below error:

Illegal assignment from List to List<Rating_Request__c>

Can anyone help where I am doing wrong. If possible provide sample code.

Not able to update custom field from Apex Class, getting Illegal assignment from List<AggregateResult> to List<Rating_Request__c>

Not able to update custom field from Apex class, getting below error:

Illegal assignment from List to List<Rating_Request__c>

Can anyone help where I am doing wrong. If possible provide sample code.

Below is my code :

public void updateflgusertb(string Selected)
{
    
    List<Rating_Request__c> usr = [SELECT ID,Question__c,Order_Sequence__c,User_Ratings__c FROM                     
        Rating_Request__c where User__c=:UserInfo.getUserId() and User_Rating__c = 0 
        group by                           
        ID,Question__c,Order_Sequence__c,User_Ratings__c 
        order by Order_Sequence__c  LIMIT 1];
    List<Rating_Request__c> rateupdate = new List<Rating_Request__c>();  
    for(Rating_Request__c objrating : usr)
    {
        objrating.User_Ratings__c = Selected;
        rateupdate.add(objrating);
    }
    update(rateupdate);
    
}

Thanks in advance

Rollback to Revision 7
Link
Adrian Larson
  • 151.4k
  • 38
  • 247
  • 431

Not able to update custom field from Apex Class, getting Illegal assignment from

edited title
Link
Tara
  • 1
  • 4

Not able to update custom field from Apex Class, getting Illegal assignment from

deleted 770 characters in body; edited title
Source Link
Tara
  • 1
  • 4
Loading
Rollback to Revision 2
Source Link
Adrian Larson
  • 151.4k
  • 38
  • 247
  • 431
Loading
Rollback to Revision 3
Link
Adrian Larson
  • 151.4k
  • 38
  • 247
  • 431
Loading
edited title
Link
Tara
  • 1
  • 4
Loading
deleted 924 characters in body
Source Link
Tara
  • 1
  • 4
Loading
minor formatting
Source Link
Raul
  • 18.9k
  • 5
  • 42
  • 70
Loading
Source Link
Tara
  • 1
  • 4
Loading