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
chriscwharrischriscwharris 

Create a child record from Homepage?

I have a number of objects in a hierarchy. The top level has some information on an person, the next child level has some balances and the third level has details. Because the objects are related I currently need to navigate via the parent to the mid level object to create the detail (3rd level) record so that the relationship fields are populated and link.

I want to be able to create the detail record direct from an action on the "Home" tab, pre-populating the relationship fields based on the currently logged in salesforce ID. I basically want to create 2 relationships automatically on creation of a record.

Is this something that can be achieved via a trigger or apex? I know you can't do this via formulas.

Thanks
srlawr uksrlawr uk
Hmm. I'm interested as to exactly how this will come about "from the home tab" - do you mean the default landing/home page, and only there? That would be difficult, the home page is remarkably hard to customise with actions!

What I can imagine I might suggest when faced with this requirement, would be to create a new Visualforce page (from develop on the setup menu) to achieve the data. You could then add a Custom Tab (from create on the setup menu) for that visualforce page. That way you have an entry point to this functionailty...

From there, with a an Apex Custom controller - the world is your oyster! you could write a fairly custom form using visualforce tags for the inputs, pre-loading all the information you want/need in the controller constructor (or an action attribute n the apex:page tag).

Once you pre-populate the fields, you can use apex:command buttons and an action method to save it all.

Only down side is that this locks the page down a bit should big customisations be made to layouts etc. but there are techniques to circumvent this and/or make the custom page a little easier (or you could just use the custom page to set up a new "tier3" object and the redirect to the standard edit page with the fields populated, thinking about it)