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
megan.burchmegan.burch 

Error in Trigger

Hi, 

 

I"m writing a trigger to populate a lookup field on the account based on a field that comes in via ETL feed. The lookup is a lookup to another account record type. I'm getting this error right now. system.stringexception invalid id external entry point

 

Below is my code

 

trigger masterchainname on Account (before insert, before update) 
{
   //create a map with a list of master chain names
   List <id> accts = new List <id> ();
   Account[] accounts = Trigger.new;
   //for each account add the MCName to the list
   for(Account a: accounts)
   {
       accts.add(a.Hotel_Chain_Name__c);
   }
    
    List <account> acclist = [select id, name, hotel_chain_name__c, chain_code_account__c from account where id in:accts];
	
    for (account a: accounts)      
    {
        	system.debug ('a.name' + a.name);
        	if (a.Hotel_Chain_Name__c != null && (Trigger.isInsert || (Trigger.isUpdate && ((Trigger.oldMap.get(a.Id).hotel_chain_name__c != a.Market__c) || (a.Chain_Code_Account__c == null) ))))
            { 
                a.Chain_Code_Account__c = a.id;
            }    
    }            
}

 

~Onkar~Onkar

If You are using This Before insert trigger you will not get the ID value.

 

 a.Chain_Code_Account__c = a.id; // You will get error here.

 

Change your trigger Event with After Insert

 

~Thanks

Onkar Kumar