function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kiru535Kiru535 

Bulkfield trigger

Technically the trigger isn't bulkified (many times for cloning I don't do that anyways b/c it's triggered by button click). But, since this is a trigger, technically you should add all the opportunities that need to be cloned to a list and pass the entire list to the helper method.

 

I am getting error in this trigger:

Error: Compile Error: Method does not exist or incorrect signature: [Cloneopty].CloneoptywithIbxline(MAP<Id,Id>) at line 44 column 9

 

Please post the code how to achive this

 

My Class :

public class Cloneopty
{

public final String ForecastStatusIsNewActive = 'New/Active';
Map<Id, Id> OppsToCloneList = new Map<Id, Id>();
//Method to check the opportunity has Slipped IBXline
public void CloneoptywithIbxline(Id oldOppoID ,Id opportunityId)
{
List<IBX_Lines__c> ibx =[Select Name,Opportunity__c,IBX_Name__c,Forecast_Status__c,Line_Type__c,Booked_Gross_MRR__c,Booked_Gross_NRR__c,Booked_Net_MRR__c,Booked_Net_NRR__c,Forecast_NRR__c,Forecast_MRR__c from IBX_Lines__c where opportunity__c =:oldOppoID AND Forecast_Status__c='Slipped'];
List<IBX_Lines__c> ibsList = new List<IBX_Lines__c>();
system.debug ('***The ibx is***'+ ibx);
for(IBX_Lines__c ib : ibx)
{
IBX_Lines__c newline = new IBX_Lines__c ();
newline.Opportunity__c= opportunityId;
newline.IBX_Name__c = ib.IBX_Name__c;
newline.Line_Type__c = ib.Line_Type__c;
newline.Forecast_Status__c = ForecastStatusIsNewActive;
newline.Forecast_NRR__c =ib.Forecast_NRR__c;
newline.Forecast_MRR__c =ib.Forecast_MRR__c;
ibsList.add(newline);

}
insert ibsList;
system.debug('***list is****'+ ibsList);
}
}

 

Trigger :

trigger Eqx_CloneOpportunity on Opportunity (after insert,Before Update)
{
// Update the clone opportunity Id - This is used to determine whether to use whether Only Slipped IBX should be cloned
if(Trigger.isUpdate && Trigger.isBefore)
{
for (Opportunity opp : Trigger.New)
{
// To avoid unndessary updates, can we check and see if the clone opportunity Id has changed

if(opp.Clone_Opportunity_ID__c == null || opp.Clone_Opportunity_ID__c != opp.ID)
{
opp.Clone_Opportunity_ID__c = opp.ID;
}
}
}

if(Trigger.isInsert && Trigger.isAfter)
{
Map<Id, Id> OppsToCloneList = new Map<Id, Id>();

for (Opportunity opp : Trigger.New)
{

system.debug('OpportunityID--->'+opp.Clone_Opportunity_ID__c);
if (opp.Clone_Opportunity_ID__c != null)

//cp.CloneoptywithIbxline(opp.Clone_Opportunity_ID__c,opp.id<http://opp.id>);
OppsToCloneList.put(opp.Clone_Opportunity_ID__c,opp.id);



}
Cloneopty cp = new Cloneopty();
cp.CloneoptywithIbxline(OppsToCloneList);

}
}

 
         
Yoganand GadekarYoganand Gadekar

Pass the correct parameters to this methode: CloneoptywithIbxline

 

if you have defined it to receive id's then pass id's only dont pass map,

 

Just make sure you pass what iyour method accepts(data type, order, number of parameters everything should be same)