1

I have a Publication object. Publications might have a very long names, longer than 80 characters. That is why Name is suppose to be populated from workflow field update, using substring from custom text field.

How can I override New button on the publication tab: enter image description here

I created the following custom button, but I do not know how to replace new button with it.

enter image description here

I read many posts online, but could not figure solution for my case.

Please advise.

EDIT I created a visual page which works with custom fields, but when I try to use ID of Name field it does not prepopulate the Name field. Do I retrieve the wrong ID, or should I use some other parameter?

URL after I click on Name field in Setup:

https://cs14.salesforce.com/p/setup/field/StandardFieldAttributes/d?id=Name&type=01Ia0000002Rgjl&retURL=%2F01Ia0000002Rgjl%3Fsetupid%3DCustomObjects&setupid=CustomObjects&rowsperpage=10000

VF page script:

<apex:page standardController="Publication__c">
  <script>
      window.top.location.href = '/a0f/e?nooverride=1&01Ia0000002Rgjl=Your+Default+Value';
  </script>
</apex:page>

Similar question and solution:

https://developer.salesforce.com/forums/ForumsMain?id=906F00000008ocDIAQ

  • I'm pretty sure you can't modify the behavior of that particular button. – Michael Welburn Jan 11 '14 at 1:27
  • Can I then modify Save button to prepopulate Name field before saving a new record ? – vlr Jan 11 '14 at 1:30
  • I also found related solution here: developer.salesforce.com/forums/… – vlr Jan 13 '14 at 21:50
1

You cannot replace that particular button with a custom button.

However, you can override the standard New button for your object which overrides that button. See the Salesforce help page for Overriding Standard Buttons for the detailed steps. The part that varies from the documented steps is the code which I’ve detailed next.

You need to create a Visualforce page that uses a standard controller. That is done by creating a page and setting the <apex:page/>’s standardController attribute to your custom object..

Technically, you could just move your URL hack into the Visualforce page and be done with it:

<apex:page standardController=“Publication__c”>
  <script>
      window.top.location.href = ‘/a0f/e?nooverride=1&01Ia0000asdf32123d=Your+Default+Value’;
  </script>
</apex:page>

Note that you need to specify the nooverride=1 parameter to ensure that you get redirected to the standard New page and not right back to your override.

Your question is a bit confusing, because you state that you need to set a value in a Workflow Rule, but then you also discuss having prepopulating a default value. The above answers the prepopulate name field with default value question (i.e., the title of your actual question). If you need to set a value on a Save of a record you can just use a Workflow Rule and Workflow Field Update. See the Salesforce help page on Creating Workflow Rules for more on that.

  • Thanks. I will try this. I need to prepopulate Name field because Workflow Field Update will not work with Name field on Save. Name should have at least some default value. It is a work around for me. After it has a default value, Workflow Rule will be able to update it. – vlr Jan 13 '14 at 18:55

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.