You need to sign in to do that
Don't have an account?
Sudhir_Meru
Update field for first time
Hi,
I am writting a triigger to update values based on the picklist value.
There is a fields Renewal which has picklist of ( Yes and No ) based on the pick list value another field will get updated which is Discount Program
My Requirement now is Discount Program must set value only for first time next time it must not set
i.e if user select Renewal (Yes) for first time it must set Discount Program to DSP next time when your select No or Yes from Renewal it must set to NSP
These two fields are on Oppertunities, Renewal_c and Discount_c
trigger NewDiscountProgramUpdate on Opportunity (before update) { // Loop through the incoming records for (Opportunity o : Trigger.new) { if ( o.Renewal_Opportunity__c == 'Yes' && o.discount_program__c == 'NSP' ) { o.discount_program__c = 'DSP'; } else { o.discount_program__c = 'NSP'; } }
Please Suggest me
How about doing this with a workflow and field updates action ?
I would use another field as a flag (i.e. renewal_set_to_nsp).
So the first time the workflow will also set the flag field and in your workflow rule you will also check the value of renewal_set_to_nsp.
All Answers
How about doing this with a workflow and field updates action ?
I would use another field as a flag (i.e. renewal_set_to_nsp).
So the first time the workflow will also set the flag field and in your workflow rule you will also check the value of renewal_set_to_nsp.
Try the code below.
Wonder full your suggestion worked for me. :) Apperciate your help