+ Start a Discussion
taaataaa 

NEED URGENT HELP!! lead Conversion

HI All,

 

I have been screwed up from the last 2 days, need help on this, in the DEV env the following code is working fine:

 

trigger trg_HAS_InfluencerAssociationWithOpportunity_AU_BU on Lead (after update)
{
Map<Id, Id> influencer2OppId = new Map<Id, Id>();
List<Opportunity> lstopp = new List<Opportunity>();
Set<Id> leadIds = new Set<Id>();

for (Integer i = 0; i < Trigger.new.size(); i++){
if (Trigger.new[i].IsConverted == true && Trigger.old[i].isConverted == false
){
{
influencer2OppId.put(Trigger.new[i].id,Trigger.new[i].convertedOpportunityId);
}
Opportunity oppty = new Opportunity(Id=Trigger.new[i].ConvertedOpportunityId);
oppty.Name=Trigger.new[i].Title;
oppty.CloseDate = System.Today().addmonths(6);
System.debug('@@@@@@@@@@@@@@  : '+oppty.CloseDate);


//oppty.StageName='Need Analysis(0%)';
lstopp.add(oppty);
}
System.debug('################  : '+lstopp);
update lstopp;

List<Influencer__c> influ = [select lead__c, opportunity__c from Influencer__c where lead__c in :influencer2OppId.keySet()];
for (Influencer__c f : influ)
{
f.check__c=false;
f.opportunity__c = influencer2OppId.get(f.lead__c);

}
update influ;

}

}

 

After deploy in ConfigDEV, I am getting error while conversion "Isuuficient Privilage", now then, I commented the bold line above in which I am updating close Date of Opportunity with 6 months ahead. it worked fine!

 

However I need that updation, so I wrote one workflow to update, again I got the same error while conversion. (While creating OPP with new button, it works fine)

 

Where I am missing?

 

Please help me in this.

 

Thanks A lot!

sivaextsivaext

Hi 

 

I think no problem with closed date. It is correct.

 

 

 

 

for (Integer i = 0; i < Trigger.new.size(); i++){
if (Trigger.new[i].IsConverted == true && Trigger.old[i].isConverted == false){

influencer2OppId.put(Trigger.new[i].id,Trigger.new[i].convertedOpportunityId);
}

}

for(Integer i=0; i<Trigger.new.size();i++) {


Opportunity oppty = new Opportunity(Id=Trigger.new[i].ConvertedOpportunityId);
oppty.Name=Trigger.new[i].Title;
oppty.CloseDate = System.Today().addmonths(6);
System.debug('@@@@@@@@@@@@@@  : '+oppty.CloseDate);


//oppty.StageName='Need Analysis(0%)';
lstopp.add(oppty);
}

}
System.debug('################  : '+lstopp);
update lstopp;