You need to sign in to do that
Don't have an account?
priya sri
Trigger for opportunity is renewal then its become clone
when ever opportunity is renewal then its become clone...
for this :::
trigger RenewalOpportunityClone on Opportunity (after update, after insert) {
List<Id> opps = new List<Id>();
for( Opportunity opp : Trigger.new ) {
if ( opp.RecordTypeId != '01290000000Hqw2' )
{
continue;
}
if( !opp.Renew_Now__c) {
continue;
}
opps.add( opp.Id );
}
Map<Id,Opportunity> oppsMap = new Map<Id,Opportunity>( [SELECT Id,OwnerId,Account.OwnerId, Original_Opportunity_ID__c,AccountId, Branch__c,Line_of_Business__c,Name,Contact__c,Renew_Now__c,Monthly_Spend__c, RecordTypeId from Opportunity where Id IN :opps] );
List<Opportunity> renewalOpps = new List<Opportunity>();
for( Opportunity opp : oppsMap.values() ) {
Opportunity renewalOpp = new Opportunity();
Date renewalDate = Date.today();
Date closeDate = Date.today();
String renewalDateString = '' + renewalDate;
renewalDateString = renewalDateString.substring(0, renewalDateString.indexOf(' '));
renewalOpp.CloseDate = closeDate + 365;
renewalOpp.OwnerId = opp.Account.OwnerId;
renewalOpp.AccountId = opp.AccountId;
renewalOpp.Contact__c= opp.Contact__c;
renewalOpp.NextStep= 'Review Account Status, send renewal notice and quote.';
renewalOpp.Monthly_Spend__c = opp.Monthly_Spend__c;
renewalOpp.StageName = 'First Meeting';
renewalOpp.Branch__c = opp.Branch__c;
renewalOpp.Line_of_Business__c= opp.Line_of_Business__c;
renewalOpp.Name = opp.Name;
renewalOpp.Original_Opportunity_ID__c=opp.Original_Opportunity_ID__c;
renewalOpp.Is_Cloned__c = true ;
renewalOpp.Cloned_from_Opportunity_ID__c='https://cs5.salesforce.com/'+opp.Id;
renewalOpps.add(renewalOpp);
opp.Renew_Now__c = false ;
opp.Is_Master__c = false ;
update opp;
}
insert renewalOpps;
}
for this :::
trigger RenewalOpportunityClone on Opportunity (after update, after insert) {
List<Id> opps = new List<Id>();
for( Opportunity opp : Trigger.new ) {
if ( opp.RecordTypeId != '01290000000Hqw2' )
{
continue;
}
if( !opp.Renew_Now__c) {
continue;
}
opps.add( opp.Id );
}
Map<Id,Opportunity> oppsMap = new Map<Id,Opportunity>( [SELECT Id,OwnerId,Account.OwnerId, Original_Opportunity_ID__c,AccountId, Branch__c,Line_of_Business__c,Name,Contact__c,Renew_Now__c,Monthly_Spend__c, RecordTypeId from Opportunity where Id IN :opps] );
List<Opportunity> renewalOpps = new List<Opportunity>();
for( Opportunity opp : oppsMap.values() ) {
Opportunity renewalOpp = new Opportunity();
Date renewalDate = Date.today();
Date closeDate = Date.today();
String renewalDateString = '' + renewalDate;
renewalDateString = renewalDateString.substring(0, renewalDateString.indexOf(' '));
renewalOpp.CloseDate = closeDate + 365;
renewalOpp.OwnerId = opp.Account.OwnerId;
renewalOpp.AccountId = opp.AccountId;
renewalOpp.Contact__c= opp.Contact__c;
renewalOpp.NextStep= 'Review Account Status, send renewal notice and quote.';
renewalOpp.Monthly_Spend__c = opp.Monthly_Spend__c;
renewalOpp.StageName = 'First Meeting';
renewalOpp.Branch__c = opp.Branch__c;
renewalOpp.Line_of_Business__c= opp.Line_of_Business__c;
renewalOpp.Name = opp.Name;
renewalOpp.Original_Opportunity_ID__c=opp.Original_Opportunity_ID__c;
renewalOpp.Is_Cloned__c = true ;
renewalOpp.Cloned_from_Opportunity_ID__c='https://cs5.salesforce.com/'+opp.Id;
renewalOpps.add(renewalOpp);
opp.Renew_Now__c = false ;
opp.Is_Master__c = false ;
update opp;
}
insert renewalOpps;
}
its not updating the close date???
it has to update close date before 90days??
thankyou sonam