I would like to know how to update a custom field in trigger.

In before insert trigger I use the setLeadStatus() method in order to update the Lead status.

public 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];
   List<Lead> updateLeadList = new List<Lead>();

    for(Lead ld :leadList) {
       boolean isLeadConverted = ld.IsConverted;
       System.debug('isLeadConverted ' + isLeadConverted);

         if (!isLeadConverted) {
           ld.Status__c = 'Existing Deal';

   update updateLeadList;

All I need to know is it possible to make an update of the Status__c field in trigger?

If it is possible could you please provide an example or some code example?

If it is not possible could you please advise whether there is some other way to update custom field in Salesforce.



  • you can update status__c field. What is the exact issue? – Ratan Paul Nov 16 '15 at 9:43
  • The issue is that for some unknown reason the Status__c field is not updated into the Lead database table and the Lead status field remains blank. If however I use the Edit button and set the field manually then and only then the field is updated into the Lead table. – Dylan D Nov 16 '15 at 9:52
  • If this is the case then i would suggest try to perform update operation in future method. – Ratan Paul Nov 16 '15 at 9:56
  • what do you mean by 'update operation in future method'? Could you please give an example? – Dylan D Nov 16 '15 at 9:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.