1

I am planning to do something like below:

  1. Create a custom detail page button to replace the save button.
  2. When user clicks the button to save a record it should execute the standard save method after setting certain additional fields on the object apart from the others set by users.

What will be the best way to do this without using visualforce page?

  • 1
    Your question assumes a specific solution; you may get more useful answers if you rephrase it around the problem you're trying to solve (e.g. "how can I set default values for a new record" or "how can I auto-fill certain fields based on a user's input in other fields") – Benj Sep 16 '12 at 4:13
-2

you could create a web-service that is called via javascript using the https://stackoverflow.com/questions/10354284/salesforce-executing-javascript-through-apex-controller

  • Anyone care to explain how my answer isn't valid? A trigger is definitely an option, but the question did not ask about setting values ALWAYS in all contexts, just in the context of the button press. In that case you want either a visualforce page or other apex class. a web-service is a light visualforce-less way of calling the custom code scoped only to the button. – ebt Sep 17 '12 at 17:38
  • I didn't down vote your answer, and while I don't think it's inappropriate, but could see how someone might see it as incomplete - more context/info on how to implement this solution to the OP's question could be helpful. – Benj Sep 19 '12 at 1:19
8

Do you want to to override the standard 'Save' button for this?

You can simply write a 'before insert, before update' trigger that will do all field setting you need before saving the record into the database

2

Another option would be to use a Workflow Rule to automatically set the fields in question automatically after the user saves the new record.

You can read more about workflow here: https://na7.salesforce.com/help/doc/en/creating_workflow_rules.htm

  • The problem here is that I want to set the fields before the record is saved. So, I think workflows will not work in this case. – Anutosh Datta Sep 17 '12 at 5:46
  • Why do you need the fields added pre-save? What's your use case? – Benj Sep 20 '12 at 13:26

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.