• EricL_Silva
  • NEWBIE
  • 0 Points
  • Member since 2009

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

Hi,

 

I'm having problems with the class Approval.ProccessSubmitRequest.

It is limited to send maximum 20 records per trigger.

I'm trying to create lists or sets, but I didn't find a way to set object ID from a list or set.

 

Can someone help me?

 

Tks

Hi, please, do someone know how can I escape from this error:

 

DML statment cannot operate on trigger.new or trigger.old

 

//Envia para aprovação a lista de preço trigger atualiza_lista_de_preco on PriceBookEntry_Approval__c (before insert, before update) { List<PriceBookEntry_Approval__c> priceBook = new List<PriceBookEntry_Approval__c>(); Set<Boolean> checkEnviaInformacao = new Set<Boolean>(); Set<ID> idLDef2 = new Set<ID>(); Set<ID> idPbDef = new Set<ID>(); Set<ID> codProd = new Set<ID>(); for (PriceBookEntry_Approval__c thisPrice : Trigger.New) { //Compara o valor de envia informação se o valor antigo for //igual ao anterior salva como falso if (thisPrice.BRM_Envia_informacao__c != false){ for (PriceBookEntry_Approval__c thisPE : Trigger.Old) { if(thisPrice.BRM_Envia_informacao__c == thisPE.BRM_Envia_informacao__c){ thisPrice.BRM_Envia_informacao__c = false; } } } //Se o valor de envia informação for falso envia para aprovação if (thisPrice.BRM_Envia_informacao__c == false){ //Envia para o fluxo de aprovação alterando o valor antes de salvar thisPrice.Process_Approval__c = true; } //Adiciona os dados necessários para o Insert ou Update para os arrays idLDef2.add(thisPrice.ID_lista_default2__c); idPbDef.add(thisPrice.ID_pricebook_default__c); checkEnviaInformacao.add(thisPrice.BRM_Envia_informacao__c); codProd.add(thisPrice.Produto__c); priceBook.add(thisPrice); } if(checkEnviaInformacao.size() > 0){ //Busca a Lista de preço e o produto da lista se existir atualiza o campo se não cria um produto novo List<PricebookEntry> PBEntry = [SELECT Id, Name, Pricebook2Id FROM PricebookEntry WHERE Id in :idLDef2 AND Pricebook2Id in :idPbDef]; Integer count = 0; List<PriceBookEntry_Approval__c> pBook = new List<PriceBookEntry_Approval__c>(); if (PBEntry.size() > 0){ //Atualiza o produto na PricebookEntry if (priceBook.size() <= 20){ update priceBook; } else { for (PriceBookEntry_Approval__c pb : priceBook){ pBook.add(pb); count++; if (pBook.size() == 20){ upsert pBook; pBook.clear(); } else if((count == priceBook.size()) && (pBook.size() < 20)){ upsert pBook; pBook.clear(); } } } }else{ if (priceBook.size() <= 20){ insert priceBook; } else { for (PriceBookEntry_Approval__c pb : priceBook){ pBook.add(pb); count++; if (pBook.size() == 20){ insert pBook; pBook.clear(); } else if((count == priceBook.size()) && (pBook.size() < 20)){ insert pBook; pBook.clear(); } } } } } }

It occours when I try to update or insert a record on the trigger above.

I needed to put all records on Lists and Sets because I'm inserting/updating a lot of records...

 

I wanted to take the insert/update code block out of the first for when it will get all records on Trigger.new, but I tried to put it into the first for and it did not work...

 

Can someone help me with that?

 

 

Thanks

 

 

Hi,

 

I'm having problems with the class Approval.ProccessSubmitRequest.

It is limited to send maximum 20 records per trigger.

I'm trying to create lists or sets, but I didn't find a way to set object ID from a list or set.

 

Can someone help me?

 

Tks

I am getting this error when I go to save my trigger "Compile Error: expecting a left angle bracket, found 'ProductName' at line 2 column 10"

 

 

trigger RenewalItemUpdate on SFDC_520_QuoteLine__c (before insert, before update) {
    List ProductName = new List();
        for (Integer i = 0; i < Trigger.new.size(); i++)
        {
            ProductName.add(Trigger.new[i].Product2__c);
        }
    List RenewalList = new List([Select Id from Annual_Renewal_Pricebook_Item__c
     where GP_Item_Number__c in :ProductName]);
        for (Integer i = 0; i < Trigger.new.size(); i++)
        {
            if (Trigger.new[i].Product2__c != null)
            {
                Trigger.new[i].GP_Item_Number__c = RenewalList[i].Id;
            }
            else
            {
            Trigger.new[i].GP_Item_Number__c = null;
            }
        }
}

 

Can anyone look at this and see why I am getting this error?  I just need a fresh set of eyes.

Thanks!