• Thibaud Navarre
  • NEWBIE
  • 10 Points
  • Member since 2016

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

Hi all,

I'm getting this error when working on visualforce page :  first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, quotesync.QuoteLineSyncTrigger: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 5 with id 00kb0000035W8kLAAS; first error: STRING_TOO_LONG  [...] (max length=255): [Univers_Description__c] Trigger.quotesync.QuoteLineSyncTrigger: line 191, column 1: []

I can't understand why it's happening, indeed this field is a Long Text Area with a 5'000 length .. 

Does anybody has an idea about what could cause this error ? 

Thx,

Thibaud.

 

Hi,

I had to rename a contact role on accounts which was "Décisionnaire" and which is now "Décisionnaire et Comptabilité".

Moreover I created a new one "Décisionnaire". This way I did not have to change the role for all my contacts.

But something really strange is happening, when I'm logged as an administrator, if I check a contact role on an account it displays correctly the role "Décisionnaire et Comptabilité" but for the same account if I'm logged as a regular user it displays the old role "Décisionnaire" and if I try to change the role for this contact as a user I can't choose "Décisionnaire et Comptabilité" there are two roles "Décisionnaire" available in the list. 

What could be the source of this problem ?

Thank you,

Thibaud

Hi,

I'm new to Salesforce and I'm struggling since a few hours on how to bulkify this trigger.

I have an object called kognoz1__Invoice2__c linked with an opportunity through a lookup field. This object has 3 email custom fields :"Relance_Email__c","Relance_CC_Email__c" and "Relance__CC2_Email__c".

The trigger must copy the emails from the Contact Role of the Opportunity linked with my custom object in those 3 previous email fields. But only when the roles of the contacts are :"Decisionnaire et Comptabilité" or "Comptabilité" and moreover when a checkbox named  "Relance_Automatique" ( which is a custom field on the contact object ) is checked. 

The fact is that an opportunity can have one, two or three contact role corresponding to the conditions that's why I'm using three email custom fields in the kognoz1__Invoice2__c object.

Here is the trigger i made, it is working fine when I'm updating the kognoz records one by one but I would like to use a Batch in order to update a lot of records and I'm getting a "too many SOQL queries Error". 

 

trigger UpdateContactEmailRelance on kognoz1__Invoice2__c (before insert, before update) {
        for(kognoz1__Invoice2__c k : trigger.new){
        List<OpportunityContactRole> Contactsearch = [Select ContactId from OpportunityContactRole where OpportunityId=:k.kognoz1__Opportunity__c and (Role='Décisionnaire et Comptabilité' or Role='Comptabilité')];
        if(Contactsearch.size()==1){
            k.Relance_CC_Email__c='';
            k.Relance_CC2_Email__c='';
            Contact email1=[Select Email, Relance_Automatique__c from Contact where Id=:Contactsearch[0].ContactId];
            if(email1.Relance_Automatique__c=true){
                k.Relance_Email__c=email1.Email;
            }
            else k.Relance_Email__c='';
        }
        if(Contactsearch.size()==2){
            k.Relance_CC2_Email__c='';
            List<Contact> emails=[Select Email, Relance_Automatique__c from Contact where (Id=:Contactsearch[0].ContactId or Id=:Contactsearch[1].ContactId) and Relance_Automatique__c=true];
            if(emails.size()==1){
                k.Relance_Email__c=emails[0].Email;
                k.Relance_CC_Email__c='';
            }
            else if(emails.size()==2){
                k.Relance_Email__c=emails[0].Email;
                k.Relance_CC_Email__c=emails[1].Email;
            }
            else{
                k.Relance_Email__c='';
                k.Relance_CC_Email__c='';
            }
        }
        if(Contactsearch.size()==3){
            List<Contact> emails=[Select Email, Relance_Automatique__c from Contact where (Id=:Contactsearch[0].ContactId or Id=:Contactsearch[1].ContactId or Id=:Contactsearch[2].ContactId) and Relance_Automatique__c=true];
            if(emails.size()==1){
                k.Relance_Email__c=emails[0].Email;
                k.Relance_CC_Email__c='';
                k.Relance_CC2_Email__c='';
            }
            else if(emails.size()==2){
                k.Relance_Email__c=emails[0].Email;
                k.Relance_CC_Email__c=emails[1].Email;
                k.Relance_CC2_Email__c='';
            }
            else if(emails.size()==3){
                k.Relance_Email__c=emails[0].Email;
                k.Relance_CC_Email__c=emails[1].Email;
                k.Relance_CC2_Email__c=emails[2].Email;
            }
            else{
                k.Relance_Email__c='';
                k.Relance_CC_Email__c='';
                k.Relance_CC2_Email__c='';
            }
        }
    }
}


I know that I must bulkify it but I can't figure out how to do it. 

Thank you in advance !

Hi,

I'm new to Salesforce and I'm struggling since a few hours on how to bulkify this trigger.

I have an object called kognoz1__Invoice2__c linked with an opportunity through a lookup field. This object has 3 email custom fields :"Relance_Email__c","Relance_CC_Email__c" and "Relance__CC2_Email__c".

The trigger must copy the emails from the Contact Role of the Opportunity linked with my custom object in those 3 previous email fields. But only when the roles of the contacts are :"Decisionnaire et Comptabilité" or "Comptabilité" and moreover when a checkbox named  "Relance_Automatique" ( which is a custom field on the contact object ) is checked. 

The fact is that an opportunity can have one, two or three contact role corresponding to the conditions that's why I'm using three email custom fields in the kognoz1__Invoice2__c object.

Here is the trigger i made, it is working fine when I'm updating the kognoz records one by one but I would like to use a Batch in order to update a lot of records and I'm getting a "too many SOQL queries Error". 

 

trigger UpdateContactEmailRelance on kognoz1__Invoice2__c (before insert, before update) {
        for(kognoz1__Invoice2__c k : trigger.new){
        List<OpportunityContactRole> Contactsearch = [Select ContactId from OpportunityContactRole where OpportunityId=:k.kognoz1__Opportunity__c and (Role='Décisionnaire et Comptabilité' or Role='Comptabilité')];
        if(Contactsearch.size()==1){
            k.Relance_CC_Email__c='';
            k.Relance_CC2_Email__c='';
            Contact email1=[Select Email, Relance_Automatique__c from Contact where Id=:Contactsearch[0].ContactId];
            if(email1.Relance_Automatique__c=true){
                k.Relance_Email__c=email1.Email;
            }
            else k.Relance_Email__c='';
        }
        if(Contactsearch.size()==2){
            k.Relance_CC2_Email__c='';
            List<Contact> emails=[Select Email, Relance_Automatique__c from Contact where (Id=:Contactsearch[0].ContactId or Id=:Contactsearch[1].ContactId) and Relance_Automatique__c=true];
            if(emails.size()==1){
                k.Relance_Email__c=emails[0].Email;
                k.Relance_CC_Email__c='';
            }
            else if(emails.size()==2){
                k.Relance_Email__c=emails[0].Email;
                k.Relance_CC_Email__c=emails[1].Email;
            }
            else{
                k.Relance_Email__c='';
                k.Relance_CC_Email__c='';
            }
        }
        if(Contactsearch.size()==3){
            List<Contact> emails=[Select Email, Relance_Automatique__c from Contact where (Id=:Contactsearch[0].ContactId or Id=:Contactsearch[1].ContactId or Id=:Contactsearch[2].ContactId) and Relance_Automatique__c=true];
            if(emails.size()==1){
                k.Relance_Email__c=emails[0].Email;
                k.Relance_CC_Email__c='';
                k.Relance_CC2_Email__c='';
            }
            else if(emails.size()==2){
                k.Relance_Email__c=emails[0].Email;
                k.Relance_CC_Email__c=emails[1].Email;
                k.Relance_CC2_Email__c='';
            }
            else if(emails.size()==3){
                k.Relance_Email__c=emails[0].Email;
                k.Relance_CC_Email__c=emails[1].Email;
                k.Relance_CC2_Email__c=emails[2].Email;
            }
            else{
                k.Relance_Email__c='';
                k.Relance_CC_Email__c='';
                k.Relance_CC2_Email__c='';
            }
        }
    }
}


I know that I must bulkify it but I can't figure out how to do it. 

Thank you in advance !