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

Dynamic Default Values for New Custom Object

I have a custom Membership object that has a master-detail relationship with Account, and a lookup relationship with Contact (an Account owns the membership and a Contact uses it). I have a list of Membership objects on the Account page as well as the Contact page, so that a user can edit a membership from either location.

The question I have concerns when a user adds a new Membership object from either the Account or Contact page. When they add a new instance from Account, SF automatically fills in the Account name. That's fine. From the Contact page, it fills in the Contact name. Also fine.

But from the Contact page, I'd also like the Contact's Account be the default for the Account field, but it is blank. A Contact only has one Account, so it is unambiguous which Account should be used.

But I can't find a way to populate the Account field on the New Membership page. A trigger won't work, since those fire when the user tries to save the new Membership object. I looked to set the default value for the Account field, but that isn't an option for master-details with standard objects.

How can I do this? Is an s-control my only option?

Thanks for any suggestions or pointers!
It's easier than that--you can use the querystring to populate the form. Instead of using the standard New button on the contact related list for memberhships, create your own button that calls a URL nearly identical to old new button, but parameterize it, putting the Contact Id and the Contact's Account Id into the right fields. There's a bunch of posts on how to do this. Study the URL structure and also use Firefox's Page Info Tool (in the menu under Tools) to see what the form names are. Turns out, if you know the form name, you can populate any fields on the form from the URL.

Hope that helps,

Hi Steve,

Well, you are correct about it being pretty easy. That is, once I had the right direction, which you supplied.

Thanks! This is working beautifully (finally).