You need to sign in to do that
Don't have an account?

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
2)App_date
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.
Thanks,
Chanti.
I have 3 fileds on opportunity. these are fields
1)status is picklist, values of status : Approved, Rejected and In progress
2)App_date
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 : Trigger.new){ if(opp.Status__c=='Approved') { opp.App_year ='YYYY'; opp.App_date =system.today(); } } }Kindly help me for Current year format, how to i will get
Thanks,
Chanti.
Can you try using System.today().year();?
The return of year() is integer, if your App_year is String please convert using the following method
String.valueOf(System.today().year());
Hope this help.