• Brianne Wilson
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Without getting too wordy:

I have a Zipcode object where the record name is a 5 digit zipcode. (Object Name = Zipcode__c)

I have a lookup field to the Zipcode object on the Account object (Field Name = Zipcode__c)


Goal If BillingPostalCode is not null, on insert/update I want to query the BillingPostalCode of the Account, search for the Zipcode record whose Name matches the Account BillingPostalCode, and attach. Note to query only on update if BillingPostalCode has been updated.

Ex: Account 123 is located in Zipcode 12345. Upon save, the Zipcode record called 12345 is located and attached to the Account in the Zipcode__c lookup field.

I know in theory how the Apex should look (create a list of Zipcode records where Name equals Account.BillingPostalCode), but having difficulty putting it into code. Any takers?
Without getting too wordy:

I have a Zipcode object where the record name is a 5 digit zipcode. (Object Name = Zipcode__c)

I have a lookup field to the Zipcode object on the Account object (Field Name = Zipcode__c)


Goal If BillingPostalCode is not null, on insert/update I want to query the BillingPostalCode of the Account, search for the Zipcode record whose Name matches the Account BillingPostalCode, and attach. Note to query only on update if BillingPostalCode has been updated.

Ex: Account 123 is located in Zipcode 12345. Upon save, the Zipcode record called 12345 is located and attached to the Account in the Zipcode__c lookup field.

I know in theory how the Apex should look (create a list of Zipcode records where Name equals Account.BillingPostalCode), but having difficulty putting it into code. Any takers?
Hi all,

I'm very new to Apex, but am convinced this scenario is possible. Problem is I can't find any examples anywhere, which surprises me.

I have a text field on Account called 'Originating_Lead__c' containing the 18 char ID of a Lead.

On the Lead is a lookup to Account.

I want to insert the ID of the Account record into the Account lookup field on the Lead record that corresponds to the ID held in the Originating_Lead__c field on Account.

I'm know I can't do this declaratively as it's "going down the tree", but I'm surprised this issue hasn't crept up before on here - have trawled right through and haven't found anything. Does anybody know of any examples of similar triggers for similar problems? 

Have browsed and used this community extensively but never posted a question - never needed to!

Thanks in advance.
Michael