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
chanti kchanti k 

How to update fields when status is approved using trigger

Hi All,

I have 3 fileds on opportunity. these are fields
1)status is picklist, values of status : Approved, Rejected and In progress
3)App year.

But Here my reuirements is when ever status is Approved then i want update App_date  and App_year. .but  App year is only current year  .

I did not get year format "YYYY".. 

please see the below eample for year .

Note :App_year = 2018.

Here my trigger.
trigger approvalupadte on Opportunity (before update, before insert)
  for(Opportunity opp :{
      opp.App_year ='YYYY';

Kindly help me for Current year format, how to i will get
Kai Herng LauKai Herng Lau
Hi Chanti,

Can you try using;?

The return of year() is integer, if your App_year is String please convert using the following method
Hope this help.