0

We have an intermediary VF page that lets users select certain values to auto fill the new record form for an object. When a user clicks Continue on our page, they are taken to the standard Salesforce new object.

We construct the URL with parameters in the Apex controller for our VF page and send the user on to it. This is fine in classic just passing along current parameters into the URL. The problem is Lightning...

I've found with Opportunities, the account Id parameter Salesforce passes is accId, then for Case the account Id parameter Salesforce passes is def_account_id. Then these parameter names don't match up to field entity definition names... and I know you pass default values in the defaultFieldValues parameter for Lightning to do URL hacking, but passing these things into that parameter does nothing as it probably wants actual field names.

But so far I can't find any way to match the random parameter names that Salesforce apparently changes for each object to any actual field name on the object. So constructing a URL and being able to handle any object just doesn't seem entirely possible...

Am I making this harder than it needs to be? Is there some trick I'm missing to passing along URL parameters in lightning and classic for any object?? Wondering if anyone has been able to figure this out or found info to do this as I have not been able to find anything.

1 Answer 1

0

Just a few thoughts which are too long for comments and could possibly be a solution:

For custom fields, you could always use the Id of the field. That is, click the field name and the URL will have the Id (ex: 00N3i000008YDBu) and you could use this in the URL like https...&00N3i000008YDBu=test. You'll need to have this field in production so that the field id remains the same across sandboxes.

For standard fields, I can see a value that works but don't know if salesforce keeps changing it:

Having the new record page opened in classic, right click on the field Account Name and inspect it using dev tools. In the resulting DOM tree, you'll notice that there's a "labelCol" and "dataCol". You'll see that there's a hidden input element with a name and id. In the screenshot below, you'll see that it's cas4_lkid in my org. When I use this with a value of a valid account record Id in the URL param, it works in pre-populating.

screenshot

I agree it's hacky and not sure if it's going to be the same across multiple salesforce releases, but just what I found.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .