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
jpbenjpben 

Custom Button - Pre-Populate Name (text) Field of a Custom Object

I have the following Button below that opens a page to add a new record for "Drugs__c".  It pre-populates the Account field on the page, but I also want to auto populate the DrugsName (Name (text)) field  with the following text, "default".  I dont want our users to worry about filling in this field since it will be overrided with a naming convention using Workflow/FieldUpdate once the record is saved.  

 

Highlighed in red is the id of the field name, "Drugs Name" in the custom object "Drugs__c".  The code is not working properly and not populating the Drug Name field.  Suggestions how to correct this.  

 

 

/a0J/e?CF00NZ0000000etH2={!Account.Name} & CF00NZ0000000etH2_lkid={!Account.Id}&retURL=%2F{!Account.Id}&01IZ00000008qBS="default"

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Rahul SharmaRahul Sharma

jpben,

 

The url parameter to be passed must be HTML Id( of InputField) of the field grabbed from edit screen.

 

So, for standard field it is same as field name, I believe(Need to check).

 

Try below code:

 

/a0J/e?CF00NZ0000000etH2={!Account.Name} & CF00NZ0000000etH2_lkid={!Account.Id}&retURL=%2F{!Account.Id}&name=default

 If it doesn't work then try replacing it with exact parameter name.

All Answers

Rahul SharmaRahul Sharma

jpben,

 

You do not need to put the text default in quotes.

 

Try code as below:

/a0J/e?CF00NZ0000000etH2={!Account.Name} & CF00NZ0000000etH2_lkid={!Account.Id}&retURL=%2F{!Account.Id}&01IZ00000008qBS=default

 

 

 

 

jpbenjpben

Removing the quotes did not work.  The field that I am trying to update is the "Name" field on the custom object.  I believe this is a standard field that could either be a text or an auto number.  I selected text for this custom object.  I know that if it is a custom object you put CF before the field id.  Is there a different process if it is a standard field? 

Rahul SharmaRahul Sharma

jpben,

 

The url parameter to be passed must be HTML Id( of InputField) of the field grabbed from edit screen.

 

So, for standard field it is same as field name, I believe(Need to check).

 

Try below code:

 

/a0J/e?CF00NZ0000000etH2={!Account.Name} & CF00NZ0000000etH2_lkid={!Account.Id}&retURL=%2F{!Account.Id}&name=default

 If it doesn't work then try replacing it with exact parameter name.

This was selected as the best answer
jpbenjpben

Thanks Rahul.  That solved it.  

vlrvlr
Thank you Rahul. 


clouduserclouduser
It didn't work for me. Any thoughts on pre populating the standard name field of a custom object?
clouduserclouduser
Working fine as below...&Name=default