I often use the quick and dirty URL hack for prepopulating fields when creating records.

I want to use a more 'secure' option. Does anyone have any recommendations on how I can accomplish this using Apex?

The only option I can think of is to have a JS button update a field which then invokes Apex via a before/after update trigger.

  • Can you add more context to your question? Do the pages use the same controller and/or same object? Visualforce or Lightning?
    – crmprogdev
    Jul 25 '16 at 14:02
  • 1
    You can create a inline visualforce page, keep it hidden on detail page. Grab the id of the page, pass it to controller and update the field.
    – MIX DML
    Jul 25 '16 at 14:05
  • @crmprogdev Sorry, yes I should of added more context, this was for the detail pages for standard and custom objects. Jul 25 '16 at 16:13

The only alternative to URL hacking is to build your own visualforce page. You can get the ID of the earlier record from the url context and then use the controller to read and pre populate any necessary data from the data base.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.