I am having a problem to update Lead status field.
I've implemented my own method which is supposed to set the Lead status field to particular value but after the method is invoked in the before insert and the before update trigger the Lead status value is not updated in the Lead table.
Here is how the method is implemented:
private void setLeadStatus(Account accountObj) {
String companyName = accountObj.name;
String accountObjWebs = accountObj.Website;
List<Lead> leadList = [SELECT company, website, status__c, IsConverted FROM Lead where company =:companyName AND website =:accountObjWebs];
for(Lead ld :leadList) {
boolean isLeadConverted = ld.IsConverted;
System.debug('isLeadConverted ' + isLeadConverted);
if (!isLeadConverted) {
ld.Status__c = 'Existing Deal';
update ld;
System.debug('ld ' + ld);
}
}
}
In debug log I see that the status is set:
DEBUG|ld Lead:{Company=emerchantpay, Website=www.emp.com, IsConverted=false, Id=00Q560000019glrEAA, Status__c=Existing Deal}
The problem is that I do not see the Status__c to be updated in Lead table. Could you please advise how to update the Status__c in the Lead table?
Regards,
Dilyan
for
loop. It won't fix the issue but the code will be much better for it.