2

I created a custom checkbox in the opportunity box so that an email is sent out to the team whenever it is checked. Issue is that an email is sent out if someone clones that opportunity. Is there a way to reset the checkbox whenever the opportunity is cloned? So that it is not checked in the new cloned opportunity?

  • What about a new opportunity that wasn't cloned? Can the checkbox be used then? – sfdcfox Sep 11 '17 at 22:27
  • a new opportunity that is created is normally not checked, so I'm not having an issue. The problem is cloning an opportunity that had that box checked. – user48169 Sep 11 '17 at 22:33
3

Create a workflow rule with evaluation criteria as when record is created and update the checkbox as unchecked via field update.

  • This is the best solution as it allows you to send on demand, you send the email you uncheck in the same workflow actions so it's ready to go for the next time and allows you to have it null when cloning. – Dan Wooding Sep 11 '17 at 23:58
2

Disclaimer: We call these URL hacks because they are hacky.

  1. Go to the opportunity fields and go to the details page for your custom field
  2. Grab the ID for the field and store it somewhere for now
  3. Remove the clone button from the page layout. Create a new button and label it "Clone" (you can give it what ever api name you want).
  4. Make the content source for the button "URL"
  5. In the forumla editor, add the following

    <instance>.my.salesforce.com/{!opportunityId}/e?clone=1&<customFieldId>=0&retURL={!opportunityId}

Note, you can use this method to set the value of ANY field when cloning a record. You can also use URL hacks like this to send users to edit pages with pre-set field values or even when creating new records.

Note2, Lookup fields require a slightly different syntax:

<fieldId>_lkid=<idOfRecord>&<fieldId>=<RecordNameField>

idOfRecord should be the exact id of the record you want pre-populated and RecordNameField should be the value in the, you guessed it, record's name field (for a contact it would be first + lastname such as "John Smith").

Note 3, Standard fields have crazy ids if you want to pre-populate them youll have to look up the names. For instance, fields on case are something like case_1. They do not have 18 digit ids as custom fields do.

Note 4, The field needs to be on the page layout and editable by the user in order for this to work. If this is an issue then you'll need to use a workflow or trigger or something. The problem with those solutions is there is no "isCloned" field that you can get access to so you're more than likely going to use the logic on insert which has the potential to impact opportunities other than the one you are cloning. For instance, if I create an opp as an admin or via an import, Ill set the box to true. It will automatically be overridden and set to false which you may not want. Implementing an "IsCloned" checkbox would require using this very hack. It'd be silly to use the hack to implement a different checkbox just so you can avoid hacking this checkbox directly.

Note 5, you can test whether you have the right Ids or syntax by clicking the clone button, copying the URL into notepad, adding in the field updates and pasting it directly into your browser.

0

May be this solution is obvious but here it is.

  1. As Santanu mentioned, create a workflow. This is better as you can get all done with configuration and no coding.

  2. For whatever reason, if that is not applicable, create a before insert trigger and reset the flag if it is checked.

  • Looks like an email still goes out even though the field does update and becomes unchecked. Ugh... I don't understand why. – user48169 Sep 12 '17 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy