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
Gaurav Jain 67Gaurav Jain 67 

Unable to compare fields from same Object in SOQL

My scenario is (I need to Add a text 'Opportunity' to end of the Opportunity Name where Opportunity Name is equal to Account Name).  I am using following code,  but getting error on line 5 that "can compare a String to Account " .. The Field Name for Account NAme is Account and thus I am comparing that ..

******************************
LIST<opportunity> OppList = New LIST<opportunity>();
for(Opportunity O: [select id , name from Opportunity ])
{
    if(O.Name==O.Account){
O.Name=O.Name + 'Opportunity';
OppList.Add(O);
    }  
}
Update OppList;
********************************

Please help
Gaurav Jain 67Gaurav Jain 67
SOLVED: Used O.Account.Name  instead of O.Account