function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Yelena GlezerYelena Glezer 

Trigger on Lead is not populating the custom field

Trigger_Test__c is successfully updating, however the  Account Owner Alias String is not - any idea what is the reason?

================================
//Class Logic

public with sharing class LeadTriggerHandler {
    public LeadTriggerHandler() {
       
    }

    public void OnBeforeInsert(Lead[] Leads){

        String companyName;
        for (Lead newLead : Leads){
            companyName = newLead.Company;
            break;
        }

        for ( Account existingAccount : [select Id, Name from Account where Name =: companyName limit 1  ]){
            //Leads[0].Company.addError('[Warning] Account exists.');
Leads[0].Trigger_Test__c=companyName;
Leads[0].Existing_Account_Owner__c= existingAccount.Account_Owner_Alias_string__c;
Best Answer chosen by Yelena Glezer
Jen BennettJen Bennett
The trigger only appears to be working on the first lead sent in by the trigger and I also don't see where you are querying for the Account_owner_alias_string__c.

All Answers

Jen BennettJen Bennett
The trigger only appears to be working on the first lead sent in by the trigger and I also don't see where you are querying for the Account_owner_alias_string__c.
This was selected as the best answer
Yelena GlezerYelena Glezer
THANK YOU!!!