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
carramrod81carramrod81 

Loading data from contact to custom object

Hi,
I Have a custom object named Trip Log that has two lookups (account and contact). The user can only create a new Trip log from the contact level. When they create a new Trip Log off of a contact, the Contact lookup is obviously filled out, but the Account lookup is blank. Is there a way it can pull the associated account from the contact and populate this box?

Also another question, is there a way to check if the selected contact is part of the selected account?

thanks
carramrod
jrotensteinjrotenstein
How are you currently creating the new Trip Log? Is the user clicking a button? (If so, can you provide the S-Control behind that button. You could probably pass the Account in the same URL.)

Please provide the code that you currently use.
werewolfwerewolf
To your first question, a simple workflow field update would do the trick.

To your second question, a validation rule would do it, just check that (for example) Contact.AccountId = AccountId.
werewolfwerewolf
Oh, wait.  *Slapping head*.  You can't update a lookup field with a workflow field update.  You can do it with an apex trigger though.
werewolfwerewolf
jrotenstein has a point but the button probably is not an Scontrol -- it's probably just the standard New button off the Contact related list, right?
carramrod81carramrod81
yes it's just a standard button, no code.
what code would i need?