You need to sign in to do that
Don't have an account?
Tigger Help - Convert string to boolean
I am trying to map the Lead Type field (picklist) to the account when the lead is converted. If the Lead Type = Salesforce.com, I want a checkbox on the account to be True. I'm missing how to convert the string to boolean to make it work.
trigger LeadTypeToAccount on Lead (before update) {
Map<Id,String> LeadType = new Map<Id,String>();
for(Lead lead : Trigger.new) {
if (lead.IsConverted) {
LeadType.put(lead.ConvertedAccountId,lead.Lead_Type__c);
}
}
List<Account> AcctList = [select Id from Account WHERE Account.Id IN :LeadType.keySet()];
for ( Account a : AcctList) {
If (LeadType = 'Salesforce.com')
a.Salesforce_com__c = LeadType.get(a.Id);
}
update AcctList;
}
***Save Error: Illegal assignment from String to Boolean
All Answers
If(leadtype='salesforce.com')
To
If(leadtype=='salesforce.com')
If salesforce_com__c is boolean ,you need to use:
A.salesforce_com__c = true;
Lead Type is actually a picklist but the field I'm trying to update on the Account is boolean
**Save Error: Comparison Arguments must be compatible types : MAP<ID,String>,String
trigger LeadTypeToAccount on Lead (before update) {
Map<Id,String> LeadType = new Map<Id,String>();
// Map of the converted Account ID and the Lead Type
for(Lead lead : Trigger.new) {
if (lead.IsConverted) {
LeadType.put(lead.ConvertedAccountId,lead.Lead_Type__c);
}
}
List<Account> AcctList = [select Id from Account WHERE Account.Id IN :LeadType.keySet()];
for ( Account a : AcctList) {
If (LeadType =='Salesforce.com')
a.Salesforce_com__c = true;
}
update AcctList;
}
Thank you!