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
AnidevAnidev 

Formula fields in trigger

Hi All,

 

Following is the error displayed when i use formula field in trigger:

Error: Compile Error: Field is not writeable: Potential__c.Contact_Status__c at line 5 column 4

 

trigger updatefield on Potential__c (after insert,after update)
{
for (Potential__c ptl:trigger.new)
{
if(ptl.Contact_Status__c='TRUE')
if(ptl.Opportunity_Stage__C!='CLOSED WON')

ptl.Opportunity_Stage__C='CLOSED WON';
}
}

 

Kindly advice as to what can be the error.

Many thanks in advance.

satheeshrsksatheeshrsk

Hi,

 

Try this

 

trigger updatefield on Potential__c (after insert,after update)
{
for (Potential__c ptl:trigger.new)
{
    if(ptl.Contact_Status__c==TRUE)
          if(ptl.Opportunity_Stage__C!='CLOSED WON')
                     ptl.Opportunity_Stage__C='CLOSED WON';
}
}

 

Thanks,

Satheesh

 

 

Prady01Prady01

Hello there, Yes you cannot update or writeable or over write a formula field via API

 

 

Hope this helps!

AnidevAnidev

Hi Satheesh,

 

Thanks for the reply.

 

Regards

Aniroodha

AnidevAnidev

Hi Pradeep,

 

Thanks for the update.

 

Regards

Aniroodha