• viadeo
  • NEWBIE
  • 75 Points
  • Member since 2011

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 12
    Replies

Hi all

 

i have a this error when i run my test 

CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, workflow2: execution of AfterUpdate caused by: System.ListException: Duplicate id in list: 

 

this my trigger  :


trigger workflow2 on Contract (after update) {
List<Account>accList=new List <Account>();
set<id>accIds = new Set<id>();
for(contract c:trigger.new)
{
accIds.add(c.AccountId);
}
Map<id,Account>accMap=new Map<id,Account>([Select(select status from contrats__r)from account Where id in :accIds]);
List<contract> myContracts =[select AccountId from contract where AccountId in :accIds and status='activé'] ;


Set<ID> myAccountsIDs = new Set<ID>(); // here we will have only the ID's of those accounts that have a contract in status 'activé'
for (contract c : myContracts)
{
myAccountsIDs.add(c.AccountId);
}
for(contract c :trigger.new)
{
account ac=accMap.get(c.AccountId);
if(c.status=='activé')
{

ac.A_I__c='active';

}


if(c.status=='expiré'&& myAccountsIDs.contains(c.AccountId) == false)
{

ac.A_I__c='inactive';

}
accList.add(ac);
}
update accList;
}

 

thanks for your help

  • February 25, 2012
  • Like
  • 0

Hi ,

 

I'm triying to develop a trigger which will change custom field on account when contract's status will change 

1/account'scustom field take 'active' value when contract's status take 'activé' value .

2/account's custom field take 'inactive 'value when contract's status take 'expiré ' value but only if there is no contract link to this account with 'activé' status .

i have wrote my code step 1 is ok but impossible to have step 2 

thanks for your suggestions

 

trigger workflow2 on Contract (After update) {
   List<Account>accList=new List <Account>();
   set<id>accIds = new Set<id>();
   for(Contract c:Trigger.new)
   {
   accIds.add(c.AccountId);
   }
   Map<id,Account>accMap=new Map<id,Account>([Select(select id,status from contracts)from Account Where id in :accIds]);
//--------------------------------------------------------------------------------------------------//
   for(Contract c:Trigger.new)
   {
   if(c.status=='activé')
   {
   account ac=accMap.get(c.AccountId);
   ac.A_I__c='active';
   accList.add(ac);
   }
   
   if(c.status=='expiré')
   {
   List<Account>conlist=new List<account>([Select(select id from contracts where Status='activé')from Account where id in :accIds]);
  
   if(conlist.size()<0)
   {
   account ac=accMap.get(c.AccountId);
   ac.A_I__c='inactive';
   accList.add(ac);
   }
   else if (conlist.size()>0)
   {
   account ac=accMap.get(c.AccountId);
   ac.A_I__c='active';
   accList.add(ac);
  }
  }
  }
   
   
   
  
   
   
//-----------------------------------------------------------------------------------------------------//
   update accList;
   }

  • February 20, 2012
  • Like
  • 0

Hi 

 

how fire a trigger only if a certain value is not present in map .to be clear status 'inactive' on account must be actived only if status on contract is 'expiré ' and also if no contract with status'activé' exist.

 

this is my trigger without the second condition

 

trigger workflow2 on Contract (before update) {
List<Account>accList=new List <Account>();
set<id>accIds = new Set<id>();

for(Contract c:Trigger.new){
accIds.add(c.AccountId);

}
Map<id,Account>accMap=new Map<id,Account>([Select(select id,status from contracts)from Account Where Id in :accIds]);


for(Contract c:Trigger.new){
if(c.status=='activé'){
account ac=accMap.get(c.AccountId);
ac.A_I__c='active';
accList.add(ac);
}
if(c.status=='expiré'){
account ac=accMap.get(c.AccountId);
ac.A_I__c='inactive';
accList.add(ac);
}

//this trigger must be fire only if in contract Map ,value 'activé' isn't there 
}

update accList;


}

  • February 17, 2012
  • Like
  • 0

Hi 

 

how fire a trigger only if a certain value is not present in map .to be clear status 'inactive' on account must be actived only if status on contract is 'expiré ' and also if no contract with status'activé' exist.

 

this is my trigger without the second condition

 

trigger workflow2 on Contract (before update) {
List<Account>accList=new List <Account>();
set<id>accIds = new Set<id>();

for(Contract c:Trigger.new){
accIds.add(c.AccountId);

}
Map<id,Account>accMap=new Map<id,Account>([Select(select id,status from contracts)from Account Where Id in :accIds]);


for(Contract c:Trigger.new){
if(c.status=='activé'){
account ac=accMap.get(c.AccountId);
ac.A_I__c='active';
accList.add(ac);
}
if(c.status=='expiré'){
account ac=accMap.get(c.AccountId);
ac.A_I__c='inactive';
accList.add(ac);
}

//this trigger must be fire only if in contract Map ,value 'activé' isn't there 
}

update accList;


}

  • February 15, 2012
  • Like
  • 0

Hello 

 

I'm trying to create a trigger wich create automatically a task when a contrat have a particular status .compilation is ok but nothing happen when i change status

this my  code 

 

trigger Training_task on Contract (after update) {

List<Contract>NewContract = trigger.new;
for(Contract a : NewContract){
if ( a.Status == 'Activé'){
Task b = new Task (Subject='Formation - Espace Emploi'+ a.Name,
OwnerId = a.OwnerId,
WhatId = a.ContractNumber,
Status = 'In progress',
Priority = 'High');
upsert b;
}
}

}

thanks for your help

  • December 06, 2011
  • Like
  • 0

This has been working in production for around a year and suddenly it stopped working over the weekend. 

 

below is the initialization section of the OpportunityControllerExtension

followed by the debugging log showing the error.

I've highlighted the offending line of code in RED.

 

This same code worked in Prod up until this weekend, and the same code also works perfectly in Sandbox. 

 

I have users who are up in arms, so any help would be appreciated.

Thanks,

Mike

 

 

public with sharing class OpportunityControllerExtension {

   private final Opportunity opp;
   private final Opportunity currentOpportunity;
   private final Account billingAccount;
   private final Account agency;
   
   private aaWSDLBeans.CampaignInfo[] campaignInfo;
   private List<OpportunitySplit> splitList;
   private List<OpportunityPartner> agencyList;
   private List<Revenue_Forecast__c> newRevenueForecasts;
   public  boolean debug;
   
   public OpportunityControllerExtension(ApexPages.StandardController stdController) {
      currentOpportunity = (Opportunity)stdController.getRecord();
      debug = false;
      this.opp = [
         SELECT
              o.StageName
            , o.Name
            , o.Estimated_Revenue_Start_Date__c
            , o.Estimated_Revenue_End_Date__c
            , o.campaign_total__c
            , o.OwnerId
            , o.AccountId
            , o.AutoIO__c
            , o.I_O__c
            , o.PO__c
            , o.account.type
            , o.account.Category__c
            , o.account.sub_category__c
            , o.billing_io_key__c
            , o.account.platform_id__c
            , o.account.agency_name__r.id
            , o.account.agency_name__r.name
            , o.account.parent.name
            , o.account.name 
            , o.account.owner.name 
            , o.account.Primary_Campaign_Manager__c 
            , o.account.owner.email 
            , o.account.BillingStreet 
            , o.account.CS_Login_First_Name__c 
            , o.account.BillingCity 
            , o.account.CS_Login_Last_Name__c  
            , o.account.BillingState 
            , o.account.Website 
            , o.account.BillingPostalCode 
            , o.account.Account_Email__c 
            , o.account.BillingCountry       
            , o.account.Phone       
             ,   (SELECT Month__c, Split_Owner__r.Name, Revenue__c, Split__c, Split_Revenue__c 
                    FROM Revenue_Forecasts__r order by Month__c, Split_Owner__r.Name)
         FROM Opportunity o
         WHERE o.id = :currentOpportunity.id];

      /*this.billingAccount = currentOpportunity.account;*/
      this.billingAccount = opp.account;
      this.agency = opp.account.agency_name__r;           
  
      this.splitList = [
         Select o.SplitPercentage, o.SplitOwnerId, o.SplitAmount
         From OpportunitySplit o
         Where o.OpportunityId = :currentOpportunity.id];
         
      if (splitList.isEmpty()) {
         splitList = new List<OpportunitySplit>();
         splitList.add(new OpportunitySplit(OpportunityId = opp.id, 
                           SplitOwnerId = opp.OwnerId, SplitPercentage = 100));
      }
      calcNewRevenueForecasts();
   }

12:01:11.275 (275088000)|SOQL_EXECUTE_BEGIN|[17]|Aggregations:1|select o.StageName, o.Name, o.Estimated_Revenue_Start_Date__c, o.Estimated_Revenue_End_Date__c, o.campaign_total__c, o.OwnerId, o.AccountId, o.AutoIO__c, o.I_O__c, o.PO__c, o.account.type, o.account.Category__c, o.account.sub_category__c, o.account.platform_id__c, o.account.agency_name__r.id, o.account.agency_name__r.name, o.account.parent.name, o.account.name, o.account.owner.name, o.account.owner.email, o.account.Primary_Campaign_Manager__c, o.account.BillingStreet, o.account.CS_Login_First_Name__c, o.account.BillingCity, o.account.CS_Login_Last_Name__c, o.account.BillingState, o.account.Website, o.account.BillingPostalCode, o.account.Account_Email__c, o.account.BillingCountry, o.account.Phone, o.billing_io_key__c, (select Month__c, Split_Owner__r.Name, Revenue__c, Split__c, Split_Revenue__c from Revenue_Forecasts__r order by Month__c, Split_Owner__r.Name) from Opportunity o where o.id = :tmpVar1
12:01:11.330 (330646000)|SOQL_EXECUTE_END|[17]|Rows:1
12:01:11.331 (331377000)|SOQL_EXECUTE_BEGIN|[60]|Aggregations:0|select o.SplitPercentage, o.SplitOwnerId, o.SplitAmount from OpportunitySplit o where o.OpportunityId = :tmpVar1
12:01:11.384 (384942000)|EXCEPTION_THROWN|[60]|System.QueryException: null
12:01:11.385 (385075000)|SYSTEM_MODE_EXIT|false
12:01:11.385 (385245000)|CODE_UNIT_FINISHED|OpportunityControllerExtension <init>

Hi all

 

i have a this error when i run my test 

CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, workflow2: execution of AfterUpdate caused by: System.ListException: Duplicate id in list: 

 

this my trigger  :


trigger workflow2 on Contract (after update) {
List<Account>accList=new List <Account>();
set<id>accIds = new Set<id>();
for(contract c:trigger.new)
{
accIds.add(c.AccountId);
}
Map<id,Account>accMap=new Map<id,Account>([Select(select status from contrats__r)from account Where id in :accIds]);
List<contract> myContracts =[select AccountId from contract where AccountId in :accIds and status='activé'] ;


Set<ID> myAccountsIDs = new Set<ID>(); // here we will have only the ID's of those accounts that have a contract in status 'activé'
for (contract c : myContracts)
{
myAccountsIDs.add(c.AccountId);
}
for(contract c :trigger.new)
{
account ac=accMap.get(c.AccountId);
if(c.status=='activé')
{

ac.A_I__c='active';

}


if(c.status=='expiré'&& myAccountsIDs.contains(c.AccountId) == false)
{

ac.A_I__c='inactive';

}
accList.add(ac);
}
update accList;
}

 

thanks for your help

  • February 25, 2012
  • Like
  • 0

Hi ,

 

I'm triying to develop a trigger which will change custom field on account when contract's status will change 

1/account'scustom field take 'active' value when contract's status take 'activé' value .

2/account's custom field take 'inactive 'value when contract's status take 'expiré ' value but only if there is no contract link to this account with 'activé' status .

i have wrote my code step 1 is ok but impossible to have step 2 

thanks for your suggestions

 

trigger workflow2 on Contract (After update) {
   List<Account>accList=new List <Account>();
   set<id>accIds = new Set<id>();
   for(Contract c:Trigger.new)
   {
   accIds.add(c.AccountId);
   }
   Map<id,Account>accMap=new Map<id,Account>([Select(select id,status from contracts)from Account Where id in :accIds]);
//--------------------------------------------------------------------------------------------------//
   for(Contract c:Trigger.new)
   {
   if(c.status=='activé')
   {
   account ac=accMap.get(c.AccountId);
   ac.A_I__c='active';
   accList.add(ac);
   }
   
   if(c.status=='expiré')
   {
   List<Account>conlist=new List<account>([Select(select id from contracts where Status='activé')from Account where id in :accIds]);
  
   if(conlist.size()<0)
   {
   account ac=accMap.get(c.AccountId);
   ac.A_I__c='inactive';
   accList.add(ac);
   }
   else if (conlist.size()>0)
   {
   account ac=accMap.get(c.AccountId);
   ac.A_I__c='active';
   accList.add(ac);
  }
  }
  }
   
   
   
  
   
   
//-----------------------------------------------------------------------------------------------------//
   update accList;
   }

  • February 20, 2012
  • Like
  • 0

Hi 

 

how fire a trigger only if a certain value is not present in map .to be clear status 'inactive' on account must be actived only if status on contract is 'expiré ' and also if no contract with status'activé' exist.

 

this is my trigger without the second condition

 

trigger workflow2 on Contract (before update) {
List<Account>accList=new List <Account>();
set<id>accIds = new Set<id>();

for(Contract c:Trigger.new){
accIds.add(c.AccountId);

}
Map<id,Account>accMap=new Map<id,Account>([Select(select id,status from contracts)from Account Where Id in :accIds]);


for(Contract c:Trigger.new){
if(c.status=='activé'){
account ac=accMap.get(c.AccountId);
ac.A_I__c='active';
accList.add(ac);
}
if(c.status=='expiré'){
account ac=accMap.get(c.AccountId);
ac.A_I__c='inactive';
accList.add(ac);
}

//this trigger must be fire only if in contract Map ,value 'activé' isn't there 
}

update accList;


}

  • February 15, 2012
  • Like
  • 0

Hello 

 

I'm trying to create a trigger wich create automatically a task when a contrat have a particular status .compilation is ok but nothing happen when i change status

this my  code 

 

trigger Training_task on Contract (after update) {

List<Contract>NewContract = trigger.new;
for(Contract a : NewContract){
if ( a.Status == 'Activé'){
Task b = new Task (Subject='Formation - Espace Emploi'+ a.Name,
OwnerId = a.OwnerId,
WhatId = a.ContractNumber,
Status = 'In progress',
Priority = 'High');
upsert b;
}
}

}

thanks for your help

  • December 06, 2011
  • Like
  • 0