function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
trigger AirplaneName on Airplane__c (before insert,before update) { if(Trigger.isInsert && Trigger.isBefore){ for(Airplane__c AR:Trigger.new){ if(AR.Gender__c=='Male' ){ AR.Name= 'MR. ' + ar.Name; } if(AR.Gender__c=='Female'){ AR.Name= 'MRS. ' + ar.Name; } } } if(Trigger.isupdate && Trigger.isBefore){ for(Airplane__c AR:Trigger.new){ Airplane__c oldplan= trigger.oldmap.get(AR.ID); if(AR.Gender__c=='Male' && oldplan.Gender__c=='Female' ){ AR.Name= AR.Name.replace('MRS. ','MR. ') ; } if(AR.Gender__c=='Female' && oldplan.Gender__c=='male' ){ AR.Name= AR.Name.replace('MR. ','MRS. ') ; } } } }
Can you confirm on which object it is? Is it on Contact object. Do you have Gender field where user fills the gender and based on it we need to prefix MR or MRS for the Name. Can you clarify more on the requirement.
Thanks
please help
Thanks for confirmation. So you have Gender field and where should it append to is it for Name?
Thanks,
Can you try the below trigger logic. Here Airplane__c is my custom object
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,