Salesforce.com Button to Create a New Record

I was answering a question in the Salesforce.com developer forums today and someone asked if the solution I offered was documented anywhere. I couldn’t find the documentation for the option – so I may as well post it here.

The function URLFOR() creates a link to somewhere in Salesforce.com without having to hard-code your server name and worry about links breaking later.  You can use this function to create another record automatically and have the system automatically press the save button too. Simply append “save=1″ at the end of the array of field values you are passing. Here are some example uses:

Create a button that updates a hidden workflow field on the record you are in. To use custom fields you must find the field ID (open the object, under fields, and open the field detail page, use the ID in the url).

{!URLFOR($Action.Account.Edit, Account.Id, [retURL=URLFOR($Action.Account.View, Account.Id), 00N300000030Ea1 ="TRUE", save=1] )}

Have an Account and you want to have 1 button that creates a renewal opportunity. You can add more fields that are important to you (close date+1 year?).

{!URLFOR($Action.Opportunity.Edit, null, [Amount = Opportunity.Amount , AccountId=Opportunity.AccountId , OwnerId = Opportunity.OwnerId, save=1] )}

sharing is good:
  • Digg
  • del.icio.us
  • Facebook
  • Reddit
  • Fark
  • TwitThis

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.