2

Suppose that at the end of each fiscal year, existing opportunities within Salesforce are "cloned." Over the course of the fiscal year, entirely new opportunities are created. So for a given fiscal year, two types of opportunities are present: 1. deals that are new to the database and 2. deals that are clones from the prior year.

Two questions:

  1. In looking at all opportunities associated with a given fiscal year, is it possible to identify which ones represent "clones" from the prior year?

  2. In cloning opportunities, is it possible to create an indicator that indicates the given opportunity is a "clone" from the prior year?

UPDATE: Dave provided a great solution to Question 2. Question 1 seems like more of a challenge (identifying which opportunities were generated through "cloning" in the past). A follow-up on Q1 in case this makes possible a solution: What if the name of the cloned opportunity is the same as it was in the prior year except for the fiscal year. I.e., CompanyABC 2014-15 (original opportunity) -> CompanyABC 2015-16 (cloned opportunity). Based on this naming convention, would there be some way to identify opportunities cloned in the past?

3

You can do that using triggers. To Answer your second question, see the explanation below

  1. First create a custom text field on Opportunity object, and let's call it RecordId.
  2. Create a workflow rule that on create, populates RecordId with SFDC Id.
  3. In our create trigger, you can check for the RecordId.
  4. If RecordId == '', then the record is new.
  5. If RecordId != ”, then the record is being cloned.

This is because trigger is executed before the workflow rule, and as a result whenever a new record is created this RecordId will not contain any value.

But when a record is being cloned this field RecordId will contain the SFDC record Id of the original object from where it is being cloned. You will be able to identify if this is new record or cloned record and take appropriate action

Actually both of your questions are related and can be answered with above solution.

Please let me know in case of any queries. If this answer helps you resolving your query, mark this as best answer.

  • Thank you, Dave! Would you be able to provide a bit more detail on how to identify the previously cloned records using triggers? Would appreciate any input. – Katherine Ranney May 30 '15 at 0:56
  • Whenever a new record is inserted, our trigger is executed before the workflow rule does, so the RecordId will be blank in trigger. When it is being cloned, RecordId will have some value(Id) and your trigger will be able to identify this. You can check order of execution here developer.salesforce.com/docs/atlas.en-us.apexcode.meta/… – Dave May 30 '15 at 1:02
  • I see. But since the workflow rule didn't exist as of the time the prior opportunities were cloned, would this still work? I'm not sure I see how it would. Thanks. – Katherine Ranney May 30 '15 at 1:04
  • If you want to set a new identifier in existing records, you can create a custom field and use workflow rule or trigger to give it some value and use that in identifying later. – Dave May 30 '15 at 1:10
  • In my knowledge, there is no identifier by default, you need to add as a new field perhaps. – Dave May 30 '15 at 1:18
1

I would create a Lookup called Cloned_From_Opportunity__c or something like that. You would set this field with the original OpportunityId with a Trigger. At this point, through workflow rules, you can pull fields such as the Close Date from the original (parent) Opportunity down to the clone so that you can evaluate the date (or this could be a x-obj formula I suppose). Adding a formula field (checkbox type) called IsClone__c would be nice for simplifying your report filters.

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.