0

I am trying to overriding a Standard button on a custom object. Unable to populate Account field. It just populates the value I enter but not the parent Account Name.

<apex:page standardController="Big_Box_Products__c"
    action="{!URLFOR($Action.Big_Box_Products__c.New, null, ['Name'='Big Box Product','cancelURL'=URLFOR($Action.Account.Tab,$ObjectType.Account),'CF00N2F000000aroL'='Account__r.Id'], true)}" />
3
  • try: <apex:page standardController="Big_Box_Products__c" action="{!URLFOR($Action.Big_Box_Products__c.New, null, ['Name'='Big Box Product','cancelURL'=URLFOR($Action.Account.Tab,$ObjectType.Account),'CF00N2F000000aroL'=Account__r.Id], true)}" /> . no quotes required around the sobject.field as SFDC will resolve this as part of the formula evaluation. That said, URL hacking doesn't always have access to lookup object fields. I have had in the past had to create an artificial cross object formula field on Account
    – cropredy
    Nov 28, 2017 at 1:55
  • Thanks for the reply. Tried the syntax and it gives a very general error: Error: Syntax error
    – Phuc
    Nov 28, 2017 at 13:39
  • Is there another alternative to pre-populating the Account and Record Name field instead of the url hack?
    – Phuc
    Nov 28, 2017 at 13:41

1 Answer 1

1

From a custom button, (type = URL, not VF), I got the following to work (this is a Classic solution as URL hacking is not allowed in LEX)

{!URLFOR($Action.Foo__c.New,null,[Name='Big Box',CF00N2F000‌​000aroL= Foo__c.Account__c ])}

Notes:

  • Quotes around the parm names are not required; SFDC parser is smart enough to realize values on the left side of = are keys, not values.
  • Fully-qualified object.field name required to reference values from the standard controller as merge fields for your lookup field.
5
  • yes I think syntax wise this will work in a Custom button for the custom object. The reason I was using the VF page was to override the standard 'new' button. This Custom object is related to an Account Object. When a user scrolls down to the Custom Object they need to be able to create a new Custom Object that is related to the Account. Thanks for your help.
    – Phuc
    Nov 28, 2017 at 17:13
  • Ok, I got the button to show but the Account field is still not populating. Is your Account field a simple lookup?
    – Phuc
    Nov 28, 2017 at 17:20
  • Yes, simple lookup
    – cropredy
    Nov 28, 2017 at 17:39
  • Tried to mirror your syntax and its telling me I am missing a right bracket. {!URLFOR($Action.Big_Box_Products__c.New,null,[Name='B‌​ig Box Product Added',CF00NE0000002aLV0= Big_Box_Products__c.Account__c])}
    – Phuc
    Nov 28, 2017 at 17:59
  • It is a direct copy-paste from my Custom Button, try selective reduction to narrow down the problem item
    – cropredy
    Nov 28, 2017 at 20:15

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.