• MattM
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
I'm developing new buttons at the Opportunity Level that will clone the Opportunity with or without some related objects !

The clone works fine (at least I think this is the best way to do it )


Opportunity opp=[Select o.qtyProductGroups__c, o.Won_Lost_Comment__c, o.State__c, o.StageName, o.Selected_Contact_Id__c, o.Remarks__c, o.RecordTypeId, o.Reason_Won__c, o.Reason_Lost__c, o.Probability, o.Primary_Opportunity__c, o.Pricebook2Id, o.Personal_Chance_of_Success__c, o.OwnerId, o.Opportunity_Type__c, o.Opportunity_Description__c, o.One_Shot_Order__c, o.IsWon, o.IsDeleted, o.IsClosed,
o.I_Internal_Status__c, o.I_Account_manager__c, o.HasOpportunityLineItem, o.ForecastCategoryName, o.ForecastCategory, o.FiscalYear,
o.FiscalQuarter, o.Fiscal, o.FAS__c, o.Expire_Date__c, o.Do_not_Show_Total__c, o.Description, o.Delivery_specifications__c, o.Customer_Reference__c, o.CurrencyIsoCode, o.Contractual_Agreement__c, o.Competitor__c, o.Competitor_Products_involved__c, o.Competitor_Pricing__c, o.Competition__c, o.CloseDate, o.Categorisation__c, o.Budget__c, o.Amount, o.AccountId From Opportunity o where id=:getOpportunityId()];
if (opp.Id != null){
Opportunity newOpp = opp.clone(false,true);
newOpp.Name=opp.Name + ' CLONE';
insert newOpp;
}



As you see I need to put in there all the fields to be cloned.
The problem is : if in the future I create a new field, this one will not be transmitted with the clone ! (unless I edit the query here and add this new field) !!!!!! Is there any solution for this ?


Tkx a lot to you all for your answers and support !

Message Edited by Mig on 01-19-2009 06:49 PM
  • January 19, 2009
  • Like
  • 0