• rameshkunta20081.3929473256963662E12
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
Hi,
i want to update salutatieon at my name, i have gender__c check box =true ,that needs to be update 'Mr.'     if it is false need to updated with 'Miss.'
im achieving that but while updating the existing record i cant replacing 'Mr.' with 'Miss.'
like gender__c=true;
kindly check this 

thank you.

trigger genderupdate1 on stdnt__c(before insert,before update)
{
list<stdnt__c> st_list=trigger.new;
for(stdnt__c st:st_list)
{
if(trigger.isinsert)
{
  if(st.gender__c==true)
  {
  st.name='Mr.'+st.name;
  }
  else
  {
  st.name='Miss.'+st.name;
  }}
if(trigger.isupdate)
{
  if(st.gender__c==true)
  {
   if(((String)st.name).startsWith('Mr.'))
   {
   st.name=st.name;
   }
   else
   {
   st.name='Mr.'+st.name;
   }}
  if(st.gender__c==false)
  {
   if(((String)st.name).startsWith('Miss.'))
   {
   st.name=st.name;
   }
   else
   {
   st.name='Miss.'+st.name;
   }}
}}}
Hi,
i want to update salutatieon at my name, i have gender__c check box =true ,that needs to be update 'Mr.'     if it is false need to updated with 'Miss.'
im achieving that but while updating the existing record i cant replacing 'Mr.' with 'Miss.'
like gender__c=true;
kindly check this 

thank you.

trigger genderupdate1 on stdnt__c(before insert,before update)
{
list<stdnt__c> st_list=trigger.new;
for(stdnt__c st:st_list)
{
if(trigger.isinsert)
{
  if(st.gender__c==true)
  {
  st.name='Mr.'+st.name;
  }
  else
  {
  st.name='Miss.'+st.name;
  }}
if(trigger.isupdate)
{
  if(st.gender__c==true)
  {
   if(((String)st.name).startsWith('Mr.'))
   {
   st.name=st.name;
   }
   else
   {
   st.name='Mr.'+st.name;
   }}
  if(st.gender__c==false)
  {
   if(((String)st.name).startsWith('Miss.'))
   {
   st.name=st.name;
   }
   else
   {
   st.name='Miss.'+st.name;
   }}
}}}