You need to sign in to do that
Don't have an account?
MUSFAR KT 6
prefix first name with Dr when new lead is created or updated.
trigger Prefix_Dr on Lead (before insert,before update) {
for(lead L:trigger.new){
L.FirstName='Dr.'+L.FirstName;
}
}
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
@istest
public class Prefix_Dr_test {
testmethod static void test(){
Lead L=New Lead();
L.FirstName='Dr.Midul';
L.LastName='ahmed';
L.Company='sfdc';
L.Status='Working-contacted';
insert L;
Lead Le=[select Id,firstname,lastname from lead where company='sfdc'];
System.assertEquals(Le.FirstName.ContainsIgnoreCase('Dr.'),'Dr.');
}
here test class is showing error
for(lead L:trigger.new){
L.FirstName='Dr.'+L.FirstName;
}
}
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
@istest
public class Prefix_Dr_test {
testmethod static void test(){
Lead L=New Lead();
L.FirstName='Dr.Midul';
L.LastName='ahmed';
L.Company='sfdc';
L.Status='Working-contacted';
insert L;
Lead Le=[select Id,firstname,lastname from lead where company='sfdc'];
System.assertEquals(Le.FirstName.ContainsIgnoreCase('Dr.'),'Dr.');
}
here test class is showing error
System.assertEquals(Le.FirstName.ContainsIgnoreCase('Dr.'),'Dr.'); In this line of code, first parameter is boolean, hence you need to make changes as below.
System.assertEquals(Le.FirstName.ContainsIgnoreCase('Dr.'), true);
test this and let us know the outcome.
Naveen
Team codengine.in
All Answers
what is the error you are seeing? add more details if you still facing the issue.
Naveen
System.assertEquals(Le.FirstName.ContainsIgnoreCase('Dr.'),'Dr.'); In this line of code, first parameter is boolean, hence you need to make changes as below.
System.assertEquals(Le.FirstName.ContainsIgnoreCase('Dr.'), true);
test this and let us know the outcome.
Naveen
Team codengine.in
I tried solving the trigger below way . I am new joiner in salesforce please let me know your suggestions @Naveen KN you've solved it amazingly.
--->
trigger Assignment17 on Lead (before insert, before update)
{
if(trigger.isbefore &&(trigger.isInsert || trigger.isUpdate))
{
for(lead Ld:trigger.new)
{
Ld.FirstName='Dr'+''+Ld.FirstName;
}
}
}
Thank You ,
Manju Bhingarkar .
bhingarkarmanju@gmail.co