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

SALUTATION TRIGGER UPDATE
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;
}}
}}}
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;
}}
}}}
i have solved this problem please take this code ...
trigger genderupdate1 on Students__c(before insert,before update) {
list<Students__c> st_list=trigger.new;
for(Students__c st:st_list)
{
String s1=st.name;
String myString = s1;
Integer result = myString.length();
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.'+ s1.substring(5,result );
}
}
if(st.Gender__c==false)
{
if(((String)st.name).startsWith('Miss.'))
{
st.name=st.name;
}
else
{
st.name='Miss.'+ s1.substring(3,result );
}
}
}}
}
Regards,
Chandra Prakash Sharma
Bisp Solution Inc.
http://bispsolutions.com
THATS WORKING GOOD
CAN YOU PLEASE EXPLAIN ME FOLLOWING
String s1=st.name;
String myString = s1;
Integer result = myString.length();
HOW IT WORKS?
CANT WE USE COMPARE,SUBSTITUTE (TEXT FUNCTION) IN THIS CASE?
AND I HAVE hitman RECORD NAME WHEN IT COMES TO UPDATE WITH GENDER CHECK BOX ITS UPDATING LIKE 'MR.MAN' , HERE MISSING HIT WHY IS IT?
THNAKS FOR YOUR HELP.
String s1=st.name; // this step st.name save on s1 String
String myString = s1; // if you want to skip this step . and directly write [ Integer result = s1.length(); ]
Integer result = myString.length(); // this step count string length and save in Integer format....
i had try to hitman problem.
but it properly working in my side.
below i am attached image ....
Thanks...