user1102898
user1102898

Reputation: 11

Sales-force Custom Object Edit page layout and Button

We have a custom object say Sales form. On edit apge of customer object we need to add a button Save and Add Product(similar to One we can have on Opportunity page). User forget to add Product/SKU after saving the sales form

New Button(Save and Add product), will save the sales-form first and then depends on record type will open the related list(child object).

Say a Sales form is for Custom Program, after save,. it will open up Custom Program relate list. If Record type is of Price Change Notification it willl open up related list of SKU detail..

Is this possible, please adivse, we have 9-10 different record type, and we don't want to re-write the application with visualforce and all customization. Re-writing with Visualforce page has some pitfalls.

Upvotes: 1

Views: 4860

Answers (1)

Matt Lacey
Matt Lacey

Reputation: 8255

As far as I'm aware, you can't replace the Save button as it's part of the Edit page and not the standard layout, so to achieve this with one button you'd need to write a custom visualforce page, this need not be complicated though — a simple custom controller which uses a standardController for management of the record would suffice.

You would call Save on the StandardController and then return a different page redirect based on the record type, the page itself would pretty much only consist of an <apex:detail> tag. If you want more details I can provide more.

If you really don't want to write any custom code or pages then you'll need to do this as a two step process, i.e. use the standard page and then have a custom "Continue" button which takes the user onto a custom URL based on the record type. I've just created a contrived version of this by doing the following:

1 - Define a custom formula field on the object, this should be of type text and can use a CASE() statement to determine the URL which the user will be taken to when hitting the button (note that this was made just for the sake of an example so it forwards to the accounts standard page for the record type 'Friend' and contacts page for 'Foe').

CASE($RecordType.DeveloperName, 'Friend', '../001/o', 'Foe', '../003/o', '')

Note the reason I use a formula field here instead of the doing this in the custom button is that for some reason you can't seem access the record types by name when defining a custom button.

2 - Define a custom button for the object called "Continue" or something similar that makes sense for you. For my example I just used the Contact object, so I referenced the custom field on my record and specified the options shown here:

options and formula for the custom button

3 - Customise the page layouts used by your record types to include this new button and you should be done!

Upvotes: 4

Related Questions