You need to sign in to do that
Don't have an account?
selva kumar 14
Trigger for copy Lead text field values into same lead lookup field
Hi Everyone,
I don't have much knowledge about coding. I have tried few triggers using some developers sample available in discussion board. But i can't able to acheive my goal. My requirement is given below.
There are a few fields that cannot be updated through the standard SalesForce interface, and can only be updated via Apex code. We need to duplicate some information from a text field on the Lead and Opportunity screens, and populate it into a lookup field. Please see the details below:
Object - Lead
Originating field (from) - Referral Text (text)
Destination field (to) - Referral Partner (lookup)
When to trigger - Upon update/Insert of Referral Text value
Can anyone please help on this.
Thanks in advance.
My trigger which i have created is given below. But it doesn't work.
trigger Referral_Lead on Lead(After insert || After Update) { {
for(Lead newLead:Trigger.new){
if (newLead.Referral_Text__c!=null) {
String refString = newLead.Referral_Text__c;
Id referralID = refString;
newLead.Referral_Partner__c = referralID;
}
}
}
}
I don't have much knowledge about coding. I have tried few triggers using some developers sample available in discussion board. But i can't able to acheive my goal. My requirement is given below.
There are a few fields that cannot be updated through the standard SalesForce interface, and can only be updated via Apex code. We need to duplicate some information from a text field on the Lead and Opportunity screens, and populate it into a lookup field. Please see the details below:
Object - Lead
Originating field (from) - Referral Text (text)
Destination field (to) - Referral Partner (lookup)
When to trigger - Upon update/Insert of Referral Text value
Can anyone please help on this.
Thanks in advance.
My trigger which i have created is given below. But it doesn't work.
trigger Referral_Lead on Lead(After insert || After Update) { {
for(Lead newLead:Trigger.new){
if (newLead.Referral_Text__c!=null) {
String refString = newLead.Referral_Text__c;
Id referralID = refString;
newLead.Referral_Partner__c = referralID;
}
}
}
}
2. While assigning String to Id, you have to type cast it. If String is a valid id, it will typecast properly, else will throw error. and you have to handle execption accordingly.