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
gopipatel_2610gopipatel_2610 

Opportunity update using Apex code

Hi All,
 
I am trying to update the custom field in the opprotunity with all the partners in the opprotunity. Custom field called "partners merge field" will be populated with all the partners related to the perticular opprotunity that has been updated. NOTE: Partners merge field is a custom text field.
 
HEre is the code I am using.
Its giving me errors called illigal assignment from array. Can anone point me out with the solution. I am new to Apex. Any help will be appreciated.
 
 
trigger UpdateOpportunity  on Opportunity bulk (after update)
 {
      for (Opportunity opp : Trigger.new)
        {
             Id OppId;     
             OppId = opp.Id;

String ThisOppPartner = [select  AccountTo.Name  From Partner  WHERE OpportunityId = :OppId ];

Opportunity op = new Opportunity
(
Id = opp.Id,
  Partners_Merge_Field__c = ThisoppPartner
  );
update op;}}
 
Thanks,
 
cloudmaniacloudmania

I think ,the problem is, "id is read only".You can not assign any value to id.