You need to sign in to do that
Don't have an account?
Daniel Gage
Convert Result of List to String Value
I asked this once before, and I said I had it. But unforunately it wasn't properly bulkified, so I ended up with the field for every lead being populated with the same information, which shouldn't happen.
So below is my code... I'm trying to get the Value of the field
memberVerification.add(mv.TFA_Salesforce_ID__c);
so that I can update the lead with it. (it is querying the entity Member_Verification__c and matching on e-mail to retrieve what the value should be)
Any help would be appreciated. The way it is right now, it only ever grabs one value and tries to put it in every lead that is inserted during an import of leads)
List<Member_Verification__c> verified = [
SELECT
Id, Verification__c ,TFA_Salesforce_ID__C
FROM
Member_Verification__c
WHERE
Verification__c IN :leadVerification
];
Set<String> memberVerification = new Set<String>();
for(Member_Verification__c mv:verified){
memberVerification.add(mv.Verification__c);
memberVerification.add(mv.TFA_Salesforce_ID__c);
TFAMV = mv.TFA_Salesforce_ID__c;
}
then later I reference it like this:
{
lead.TFA_Salesforce_ID__c = TFAME ;
lead.Verified__c = True;
}
So below is my code... I'm trying to get the Value of the field
memberVerification.add(mv.TFA_Salesforce_ID__c);
so that I can update the lead with it. (it is querying the entity Member_Verification__c and matching on e-mail to retrieve what the value should be)
Any help would be appreciated. The way it is right now, it only ever grabs one value and tries to put it in every lead that is inserted during an import of leads)
List<Member_Verification__c> verified = [
SELECT
Id, Verification__c ,TFA_Salesforce_ID__C
FROM
Member_Verification__c
WHERE
Verification__c IN :leadVerification
];
Set<String> memberVerification = new Set<String>();
for(Member_Verification__c mv:verified){
memberVerification.add(mv.Verification__c);
memberVerification.add(mv.TFA_Salesforce_ID__c);
TFAMV = mv.TFA_Salesforce_ID__c;
}
then later I reference it like this:
{
lead.TFA_Salesforce_ID__c = TFAME ;
lead.Verified__c = True;
}
Here we go:
Important :
If this is what you were looking for then please mark it as a "SOLUTION" or You can Click on the "Like" Button if this was beneficial for you.
All Answers
Right now it's a trigger.. not a class... I know it should be a class. But I'm fairly new to this and haven't quite worked out how to make this a class yet. The problem is that TFAME variable doesn't change for multiple uploads, so it's only checking it once, but I thought the way I had it would reference it for every loaded lead.
Anyway.. here it is. Any and all suggestions are very appreciated.
trigger UpdateVerifyLead on Lead (before insert, before update) {
List<String> leadEmails = new List<String>();
for(Lead lead:Trigger.new){
leadEmails.add(lead.Email);
}
List<Member_Verification__c> email = [
SELECT
Id, Primary_Email__c,TFA_Salesforce_ID__C
FROM
Member_Verification__c
WHERE
Primary_Email__c != null and Primary_Email__c IN :leadEmails
];
string TFAME;
Set<String> memberEmails = new Set<String>();
for(Member_Verification__c member:email){
memberEmails.add(member.Primary_Email__c);
memberEmails.add(member.TFA_Salesforce_ID__c);
TFAME = member.TFA_Salesforce_ID__c;
}
for (Lead lead:Trigger.new)
{
if(memberemails.contains(Lead.Email))
{
lead.TFA_Salesforce_ID__c = TFAME ;
lead.Verified__c = True;
}
Here we go:
Important :
If this is what you were looking for then please mark it as a "SOLUTION" or You can Click on the "Like" Button if this was beneficial for you.
Or am I missing something?
First, thank you for your help. I am new to SF developing (I'm a C# guy).. and any help is greatly appreciated.
I just tested this code out, and it's doing the same thing my original code was doing. It seems that it is only grabbing the TFA SF ID from the first lead object in the list and populating it to all in the Bulk Import process. This code works fine on manual creation. But not on imports of multiple leads.
Okay... So it might not be the code that isn't working. Because it never actually updated. When I finally figured out why it wasn't saving, I get this error when trying to save the above provided code.
Error: Compile Error: Expression cannot be assigned at line -1 column -1
for(Lead leadObj:Trigger.new){
if(PrimaryEmailMemberVerificationMap.ContainsKey(leadObj.Email)){
lead.TFA_Salesforce_ID__c = PrimaryEmailMemberVerificationMap.get(leadObj.Email).TFA_Salesforce_ID__C ;
lead.Verified__c = True;
}
}
But I don't see what could be wrong about it.