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
manjirimanjiri 

How to Add new button on custom object lookup

Hi,

 

In lookups for standard object, we have New button on lookup dialig.

Is it possible to have New button on lookup dialog for Cutom Object. If yes please let me know the steps or workaround

 

Thanks

andrewfoggandrewfogg

Hi @manjiri, 

 

 

There is a work around to be found in the online help.  Copied below.  It is a little inelegant though.  I too would like the functionality that you describe: a 'new' button in a custom-object relationship lookup-window that allowed a new custom-object to be created, same behaviour as with Account records say.  

 

 


  

How to create new records from a lookup search?

 

Frustrated of not finding the person you're looking to add through a lookup search and having to exit out of the search to create that record?  Well now you can create a link in the lookup search that will allow you to create that record from the search itself.

To best explain this, lets pretend that you want to be able to create a new Account through any lookup field. A likely reason would be that you're entering a contact or an opportunity and you're trying to link the contact or opportunity to an Account, however their account doesn't exist so you want to create one.

First, you will want to create a custom formula text field on the Accounts object (or the object that you wish to create a new record for, whatever it may be). 
Go to: | Setup Customize (Whatever Object) | Fields New Formula Text |

Your formula should look something like this:

HYPERLINK("https://na5.salesforce.com/001/e?retURL=%2F001%2Fo", "Create a New Account")

Note: The URL that you want to use is the same URL of the page when creating a new account.  This URL will vary per org and per object.  To get the appropriate URL, go to the tab of the new record you wish to create and click to create a new record for that object.  When you're prompted with the typical new screen for a record (with essentially no information and all editable fields) this is the URL you want to use.  

The text in the quotes is how your Hyperlink will appear.

Save the field and DO NOT ADD IT TO THE PAGE LAYOUT.  It is not necessary for this field to be added to the page layout.

Next, you want to add this to the Search Layout for Lookup Dialogs.  
Go to: | Setup | Accounts | Search Layouts | Lookup Dialogs | and find the Custom Formula field that you just created and add it.

You will now be able to create a new Account from any Account Lookup field by selecting the exposed link(your custom formula text hyperlink) from the lookup search. 

Aleph8Aleph8

Wow, this "works", but is an insanely ugly hack from any perspective.

 

Is this really what force.com development is like?  Probably time to nix using force.com and switch to a real platform before we commit.

Paul.FoxPaul.Fox

There are a few locations where Salesforce has not exposed the ability to configure it. This is a bad example of force.com development. Most other platforms wouldn't give you the ability to configure anything though, so this is still better than nothing.

 

If you want a more elegant workaround from a coding standpoint, then here ya go:

 

1. Don't bother trying to change the lookup, since Salesforce doesn't let you customize it.

2. Create a custom button on the custom object that says Create New Parent Account (or something like that). Have the custom button pass the custom object ID to a visualforce page.

3. Create a visualforce page that replicates the Account detail page, but overrides the Save function with a custom controller. In the custom controller, have it insert the Account, and then add the Account ID to the lookup field on your custom object, and then return a pagereference which sends the user back to the custom object. (This sounds hard but it's about an hour of work if you know Visualforce and Apex).

 

The obvious downside is that users may not notice the button if they're already in the lookup. But with some really short training you can handle that, at least until Salesforce adds this capability to custom objects or gives us the ability to modify the lookup page (or override it with our own custom page).

elrenesonelreneson

I'm dealing with this same issue for custom objects.

The Account Lookup already have a "New" button (although you cannot customize the form), that will create a new record with the default record type.

However I can see it only for accounts, any new way or new salesforce feature to have one for custom objects?

 

Thanks !

 

docbilldocbill

This will work if an only if at least one record is returned by the lookup search, and then the link appears for each record.

 

That might not be bad if the link was for a clone operation, but it just does not meet the needs of being able to add a new record when none exists.

 

I have a hack that will work, but is so ugly and kludgy I won't mention it here.

 

 

boilermakerjmboilermakerjm

I followed these steps, but the formula field will not show up in the lookup dialog. To make sure I was adding it to the right dialog I added another column : created date and that shows up fine. But even the column header will not show up for this hyperlink forumla.

DovaDova
If you do not want to do a hack, nor apex and do not use "Quick Create" a solution could be to

1. Create a custom button for your custom object
  1.a Make it a "Detail Page Button"
  1.b and "Display in new window"
  1.c set url to "/{!$ObjectType.Account}/e"
2. Expose it on the detail page of your custom object

after saving and killing the new window the account is available for lookup

AddaAdda
Hi,

Please help me here. I am trying implement same functionality. On case when a user select an account or create a new account, they use regular new button on lookup dialog. But once they want to create a new contact on lookup, I want to create a new formula field. But the purpose formula field is to pass pre-populated field like account name and default record type and so on. But the formula doesn't seems to help. Here it is. It works very well as button but as a formula when I save it, the formula removes some important character like { , ! and then it doesn't work.

Do you have any idea how I can translate pre-populated functionality on formula. Sorry if I didn't make this clear.

Custom Button:
https://cs30.salesforce.com/003/e?retURL=%2F003%2Fo&con4={!Case.Account}&con10={!Account.Phone}&RecordType=012n00000008Wq0&ent=Contact
On formula, it turns like this
HYPERLINK("https://cs30.salesforce.com/003/e?retURL=%2F003%2Fo&con4=Case.Account&con10=Account.Phone&RecordType=012n00000008Wq0&ent=Contact", "Create a Contact")


Thanks
Adda
asco gundaasco gunda
Did anyone got solution for elreneson question :

I'm dealing with this same issue for custom objects.
The Account Lookup already have a "New" button (although you cannot customize the form), that will create a new record with the default record type.

I need to create a accounts of particular record types but now only "standard" default record type account is created.
 

Thanks !
Conor Gleeson 6Conor Gleeson 6
Hi @Asco, change the default page layout for the profile of the person who will be creating the account - change it to your required layout and this will work.

Hope this helps,
Conor
Sourav PSourav P
Hello  @andrewfogg, I have the same things to do. But getting issue here, if anybody can check.
I created a formula hyperlink field, in object " Quotation" for a look up object as " Car". Then i went to the Quotation search layout, Look up Dialogs and added the new formula field. But till there is no " create" button coming in my Look up. rather then its just coming as a field in the quotation page.
User-added image

User-added image

Till no " create" button here,

User-added image


 
Behnoosh NematiBehnoosh Nemati
Hi All,

I have the same issue. I have a custom object called  Supplier and user needs to be able to have New button in the lookup page.. I tried the above mentioned solution but it is not working.. it just added a new column and in case of showing no records, there is no like.  I need abutton just like GO button. Can you please help?
Prince_sfdcPrince_sfdc
Setup | Customize | User Interface and check "Show Quick Create".
Nikhol GaritaNikhol Garita
In lookups for standard object, is not possible to add a New Custom Button on lookup dialog (except for this workaround). Is this issue still happening?