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
tammyCMCtammyCMC 

custom buttons and saveURLs

 

I have a custom object which has Additional Clients Visited as a related list.

 

I need to change the button shown above (New Additional Client Visited)

I want the new button to bring me back to this custom object after a new client visited is created.

FIRST PROBLEM: I can't figure out where to go to change what button shows in this related list.

 

At the moment the url when you click the New Additional Client Visited button is :

https://na4.salesforce.com/a0m/e?CF00N60000001pX9E=T-0393&CF00N60000001pX9E_lkid=a056000000INcoG&retURL=%2Fa056000000INcoG

I've done a little searching and found that I likely need to have the replacement button provide a SaveURL

SECOND PROBLEM: I don't know what the url should be to bring me back to the custom object (Trip_Report__c) instead

 

Thanks for any help!

Tammy

sfdcfoxsfdcfox

The correct URL you should be using is not a URL at all, but rather a formula:

 

{!URLFOR(
  $Action.Additional_Clients_Visited__c.New,
  null,
  [ retURL="/" & Additional_Clients_Visited__c.Id,
    saveURL="/" & Additional_Clients_Visited__c.Id,
    CF00N60000001pX9E={!Additional_Clients_Visited__c.Name},
    CF00N60000001pX9E_lkid=Additional_Clients_Visited__c.Id
  ],
  true)}

URLFOR constructs a valid URL for you to use. It accepts up to 4 parameters (all are mentioend here for completeness). The first parameter is the action you wish to invoke (I made an assumption based on your object's name). The second parameter is the record we are editing; it is null because it is new, but if we were editing an existing record, we would provide the current record's ID. The third parameter is a NVP (name-value pair) array; these will be placed directly in the URL; values here will override default values. Finally, the fourth parameter tells salesforce.com if we want to override a page override (an s-control or Visualforce page that is configured to handle that particular action). By placing true here, we force the default page to appear. We could also use false, which is to let the default action happen (go to override page if configured). This parameter can be left out completely, in which case it is the same as false. You may need to experiment with the parameters a little bit, as URLFOR is underdocumented and buggy (e.g. won't accept field names that start wtih a 0, as some older fields do). However, I hope this post will help you out.

 

As far as adding the button, you'll want to go to your custom object (the one you are adding it to, the Additional Client Visited object), and add the custom button there. It has a List type behavior, without multi-select checkboxes enabled, and opens a URL in the same window withuot sidebar or header. Once all this is set up, the only thing left to do is to place it on the page layout. Go to the layout where you would like to have the button appear (the parent object, which isn't named here, but I assume has a tab located at https://na4.salesforce.com/a05/o). Edit the page layout, double-click on the Additional Clients Visited related list, click the Buttons selection (near the bottom), and add the custom button (and, presumably, remove the default button). After all this, you're done!