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
RichardC.ax220RichardC.ax220 

Master ID is "Invalid parameter for function URLFOR" in detail custom button

I have an app with master and detail custom objects. I created a custom button in the detail custom object
to create a new detail object using the following formula:

{!URLFOR( $Action.Detail__c.New,   Detail__c.MasterId__c  )}

It worked fine when I first tested it, opening a "New" form for the detail object with a reference to it's master. Now it fails with "Invalid parameter for function URLFOR", even though the parameter is a valid merge field included from the builder. It works if I remove the Detail__c.MasterId__c parameter, but the New form no longer has the reference to the Master.

Has anyone seen this, or know of a solution?
sfdcfoxsfdcfox
You are probably trying to do this:

{!URLFOR( $Action.Detail__c.New,  null, [retURL=Detail__c.MasterId__c], true)}

This will provide the New page, with no ID for the current record ("null"), and a return value ("retURL") of the master record. Also, you'll need the "true" if you're overriding the object's default new button, otherwise this may be omitted or "false".

~ sfdcfox ~
RichardC.ax220RichardC.ax220
sfdcfox,
 
Thanks for the suggestion. I gave it a try and got a new form for the detail record, but the lookup for the master record is empty. The button is a shortcut to create a new detail record from an existing detail record's details page. The user is already in the context of a master record and expects to stay "under" that master record. Specifying the master record ID as the second ("id") argument used to fill in the master lookup, as if the user clicked the New button on the detail related list, but apparently no more :smileysad:
LalitLalit

Did you get any solution to this problem, I have a similar requirement how can we pass Master Object ID(Name) to child object.

After