You need to sign in to do that
Don't have an account?
prasanth puvvada 4
trigger for changing values after edit
hi freinds, my senario is in account object if we click of "new" then it will show form, in that one, i put a condition called "if gender == male" then add "Mr." to the front of the name and if gender==felmale then add "Mrs." to the front of the name. So i created gender field on page. And i wrote a before insert trigger. ( well this is working fine).
Problem: after saving the record then, if i change the gender value then the name NAME also should update correctly. (example, if i change value from male to female then is should change as "Mrs." please help me what to add in this code or i need to add another code for this problem.
|Before insert code:-
screen shot for edit page.
Problem: after saving the record then, if i change the gender value then the name NAME also should update correctly. (example, if i change value from male to female then is should change as "Mrs." please help me what to add in this code or i need to add another code for this problem.
|Before insert code:-
trigger beforetriggergender on Account (before insert) { for(account a:trigger.new) { if(a.gender_of_owner__c=='male') a.name='Mr. '+a.name; if(a.gender_of_owner__c=='female') a.name='Mrs. '+a.name; } }
screen shot for edit page.
Please let us know if this will help you
All Answers
Please try below code:- NOTE:- You Just need to before Update event in your same trigger.
Please mark this as solution if this will help you. So That if any one has same problem then this post can help.
Thanks
Amit Chaudhary
I think the first parameter which you have used is correct i.e after insert but the next time when you are editing the field value than you are not acctually inserting anythin this time you are updating so in the trigger also use after update.
could u tell me the logic for removing the Mr. or Mrs checking if they are in name ? Thanks in advance. please see the screenshot.
Please let us know if this will help you