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
Irwin_FletcherIrwin_Fletcher 

How to pass info into "New" form for sObject

When you make a new record of an sObject and it shows the various fields, I noticed that if you append ?fieldId=123 to the URL you can pass information to it to prepopulate the fields. Unfortunately I don't see any other way to get the fieldId other than viewing the source of the form. Is there a way to retrieve this id programattically?
werewolfwerewolf
There is not any programmatic way.  Fair warning, too -- those field IDs could change (although they usually don't).
Irwin_FletcherIrwin_Fletcher
Are there any other solutions? Screen scrape + regex to get the id out?
werewolfwerewolf
Ooh, I definitely wouldn't do that, that sounds exceedingly fragile.  How about creating the object in advance, filling those fields as appropriate, and then going to the edit screen of the precreated object?
Irwin_FletcherIrwin_Fletcher
That's how it's currently setup but there is a need for the ability to select a record type.
werewolfwerewolf
Hmm.  Ok, well how about using the record type select page first, but set its save_new_url to point to your Scontrol which creates the object, then redirects the page to the edit screen for that object?  I believe the record type page will stick the chosen record type right into the URL which you can parse in your Scontrol using one of the $Request fields.

So basically you make your custom button such that it constructs a record type select URL as above.