0

I would like to create a custom button to clone a record and set 3 custom fields to new values. Ideally, when cloning, we would use a VF page that only allows the user to change the Name field. F1__c is a picklist, F2__c & F3__c are checkboxes.

Setting the field values is mandatory, calling the VF page is a really nice to have, but not mandatory. I should be able to use the existing VF edit page as a template for the new page, so just need to be able to call it somehow in the button if possible. Values will be "New", FALSE & FALSE respectively.

I'm trying to use javascript to create the clone button. The clone part of the javascript seems really easy and I've got that working. But, I'm not having any luck finding instruction/syntax on how to set values for fields.

Can anyone help with, or point me in the right direction, on how to set field values using javascript and, how to call a VF page using javascript if possible.

Thanks!

1 Answer 1

0

Someone else can probably help with the VF page, but to meet your minimum requirement we can avoid javascript all together and just use a custom button like below:

/{!Opportunity.Id}/e?clone=1&retURL=%2F{!Opportunity.Id} and add &customField.Id=Value for each field you want pre-populated.

enter image description here

2
  • Awesome, thanks!
    – supergreat
    Commented May 3, 2016 at 15:51
  • Wanted to report back that using your example I was able to get it working. It also looks like I can use the 'Overriden' checkbox for the button use a VF page, so you've made my day much easier. Thanks again!
    – supergreat
    Commented May 3, 2016 at 16:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .