Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7604113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:49:35+00:00 2026-05-30T23:49:35+00:00

I have a simple trigger which pulls data from the lead object and places

  • 0

I have a simple trigger which pulls data from the lead object and places it into a custom “Finance” object when the lead is created or updated. For some reason, the Trigger.new[i].Id is returning NULL in the trigger which fires before insert.

I’m going crazy because I can’t see any reason why the Id would be NULL… Here’s my code:

trigger FinanceNew on Lead (before insert) {

Map<String,User> userList = new Map<String,User>{};

// Places each returned user into a map with their sfID as the key
for(User tmp : [SELECT Id,Name,Email,Phone FROM User]){
  userList.put(tmp.Id,tmp);
}

for(integer i = 0; i<Trigger.new.size(); i++){

    string leadName = null;

    if(Trigger.new[i].FirstName != ''){
        leadName = Trigger.new[i].FirstName + ' ' + Trigger.new[i].LastName;
    }else{
        leadName = Trigger.new[i].LastName;
    }

    User ownerInfo = userList.get(Trigger.new[i].OwnerId);

    ID leadId = Trigger.new[i].Id; // THIS IS RETURNING NULL!!

    Finance__c financeRecord = new Finance__c(

        Name = leadName,
        Lead__c = leadId,
        Lead_Email__c = Trigger.new[i].Email,
        Lead_Phone__c = Trigger.new[i].Phone,
        Lead_Owner_Name__c  = ownerInfo.Name,
        Lead_Owner_Email__c = ownerInfo.Email,
        Lead_Owner_Phone__c = ownerInfo.Phone

    );

    insert financeRecord;

    }

}

Thank you in advance for any help given!

Josh

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T23:49:37+00:00Added an answer on May 30, 2026 at 11:49 pm

    For some reason, the Trigger.new[i].Id is returning NULL in the trigger which fires before insert.

    SFDC records don’t have ID’s before they are inserted. The process of insertion creates the ID. You probably want to use after insert.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simple SSIS package which reads data from flat file and insert into
I have simple SSIS package where I import data from flat file into SQL
I have simple SSIS package in which On Error event handler I have created
I have a simple .Net enum. I also have a view model object which
I have a simple scenrio in which, Enter key press should trigger the submit
I have a simple android application which does search. I have a custom popup
I have problem with creating a simple MySQL trigger in C#. I'm using StringBuilder
I have a simple problem. Using the IsPressed trigger i want to be able
I have a simple query over a table, which returns results like the following:
I have to dash away from the computer frequently, and I want to trigger

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.