• Thron
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies
Hello, looking for a little help from some of the formula / validation gurus around here please.

We have 4 custom fields on the Opportunity which are calculated revenues etc. from an APEX class. When the user creates a new Opportunity we don't want them to be able to put anything in those fields (text boxes). But once it has calculated and entered a value in the text boxes we want the restriction to be lifted and the user able to potentially edit them if need be.

I've thought of a few clunky ways to add this into my APEX class but I was hoping there was an easier solution via a formula perhaps? I'm not as proficient with formulas or validation rules so I was hoping maybe someone here had an idea.

Appreciate the help in advance, thanks!
-Jon
  • June 03, 2014
  • Like
  • 0

Hello, I'm having a strange issue where I'm getting too many code statements: 20001 on this trigger:

 


trigger UpdateLeadPass on Lead (before update) {
    
    Lead[] lead = Trigger.new;
    Lead[] oldLead = Trigger.old;

    if(Trigger.isUpdate) {    
        if (lead != null && oldLead != null){
            for(Lead leadPointer : lead) {
                for (Lead oldPointer : oldLead) {
                    if (leadPointer.bdr_to_sr__c == True){
                        leadPointer.bdr_to_sr_rep__c = UserInfo.getUserId();
                        leadPointer.Transfer_Date__c = System.Now();
                    } else if (oldPointer.bdr_to_sr__c == True && leadPointer.bdr_to_sr__c == false) {
                        leadPointer.bdr_to_sr_rep__c = null;
                    }
                    if (leadPointer.bdr_to_ae__c == True){
                        leadPointer.bdr_to_ae_rep__c = UserInfo.getUserId();
                        leadPointer.Transfer_Date__c = System.Now();
                    } else if (oldPointer.bdr_to_ae__c == True && leadPointer.bdr_to_ae__c == false) {
                        leadPointer.bdr_to_ae_rep__c = null;
                    }
                    if (leadPointer.bdr_to_reseller__c == True){
                        leadPointer.bdr_to_reseller_rep__c = UserInfo.getUserId();
                        leadPointer.Transfer_Date__c = System.Now();
                    } else if (oldPointer.bdr_to_reseller__c == True && leadPointer.bdr_to_reseller__c == false) {
                        leadPointer.bdr_to_reseller_rep__c = null;
                    }
                    if (leadPointer.sr_to_ae__c == True){
                        leadPointer.sr_to_ae_rep__c = UserInfo.getUserId();
                        leadPointer.Transfer_Date__c = System.Now();
                    } else if (oldPointer.sr_to_ae__c == True && leadPointer.sr_to_ae__c == false) {
                        leadPointer.sr_to_ae_rep__c = null;
                    }
                    if (leadPointer.sr_to_reseller__c == True){
                        leadPointer.sr_to_reseller_rep__c = UserInfo.getUserId();
                        leadPointer.Transfer_Date__c = System.Now();
                    } else if (oldPointer.sr_to_reseller__c == True && leadPointer.sr_to_reseller__c == false){
                        leadPointer.sr_to_reseller_rep__c = null;
                    }
                    if (leadPointer.ae_to_reseller__c == True){
                        leadPointer.ae_to_reseller_rep__c = UserInfo.getUserId();
                        leadPointer.Transfer_Date__c = System.Now();
                    } else if (oldPointer.ae_to_reseller__c == True && leadPointer.sr_to_reseller__c == false) {
                        leadPointer.ae_to_reseller_rep__c = null;
                    }
                }
            }    
        }
    }
}

 

 

The Trigger is very simple so I don't understand where this is happening? Strange thing as well, if I load let's say 350 leads the first 200 will get this error and the next 150 will load fine. If I reduce that too 300 leads loaded the first 200 still error and the next 100 make it in just fine.

 

Any help is very appreciated thank you!

 

-Jon

  • September 10, 2013
  • Like
  • 0

Hello, sorry if this has been answered before I've done a search on here and google and haven't found this specifically. 

 

Do commands such as System.Now() or UserInfo.getUserId(); etc. count as DML requests?

 

Here is the code in question where I'm running into the issue pretty simple stuff:

 

 

 

trigger UpdateLeadPass on Lead (before update) {
    
    Lead[] lead = Trigger.new;
    Lead[] oldLead = Trigger.old;
    
    if (lead != null && oldLead != null){
        for(Lead leadPointer : lead) {
            for (Lead oldPointer : oldLead) {
                if (leadPointer.bdr_to_sr__c == True){
                    leadPointer.bdr_to_sr_rep__c = UserInfo.getUserId();
                    leadPointer.Transfer_Date__c = System.Now();
                } else if (oldPointer.bdr_to_sr__c == True && leadPointer.bdr_to_sr__c == false) {
                    leadPointer.bdr_to_sr_rep__c = null;
                }
                if (leadPointer.bdr_to_ae__c == True){
                    leadPointer.bdr_to_ae_rep__c = UserInfo.getUserId();
                    leadPointer.Transfer_Date__c = System.Now();
                } else if (oldPointer.bdr_to_ae__c == True && leadPointer.bdr_to_ae__c == false) {
                    leadPointer.bdr_to_ae_rep__c = null;
                }
                if (leadPointer.bdr_to_reseller__c == True){
                    leadPointer.bdr_to_reseller_rep__c = UserInfo.getUserId();
                    leadPointer.Transfer_Date__c = System.Now();
                } else if (oldPointer.bdr_to_reseller__c == True && leadPointer.bdr_to_reseller__c == false) {
                    leadPointer.bdr_to_reseller_rep__c = null;
                }
                if (leadPointer.sr_to_ae__c == True){
                    leadPointer.sr_to_ae_rep__c = UserInfo.getUserId();
                    leadPointer.Transfer_Date__c = System.Now();
                } else if (oldPointer.sr_to_ae__c == True && leadPointer.sr_to_ae__c == false) {
                    leadPointer.sr_to_ae_rep__c = null;
                }
                if (leadPointer.sr_to_reseller__c == True){
                    leadPointer.sr_to_reseller_rep__c = UserInfo.getUserId();
                    leadPointer.Transfer_Date__c = System.Now();
                } else if (oldPointer.sr_to_reseller__c == True && leadPointer.sr_to_reseller__c == false){
                    leadPointer.sr_to_reseller_rep__c = null;
                }
                if (leadPointer.ae_to_reseller__c == True){
                    leadPointer.ae_to_reseller_rep__c = UserInfo.getUserId();
                    leadPointer.Transfer_Date__c = System.Now();
                } else if (oldPointer.ae_to_reseller__c == True && leadPointer.sr_to_reseller__c == false) {
                    leadPointer.ae_to_reseller_rep__c = null;
                }
            }
        }    
    }
}

 

 

I appreciate any responses, thank you!

 

-Jonathan

  • September 04, 2013
  • Like
  • 0

Hello, I'm having a strange issue where I'm getting too many code statements: 20001 on this trigger:

 


trigger UpdateLeadPass on Lead (before update) {
    
    Lead[] lead = Trigger.new;
    Lead[] oldLead = Trigger.old;

    if(Trigger.isUpdate) {    
        if (lead != null && oldLead != null){
            for(Lead leadPointer : lead) {
                for (Lead oldPointer : oldLead) {
                    if (leadPointer.bdr_to_sr__c == True){
                        leadPointer.bdr_to_sr_rep__c = UserInfo.getUserId();
                        leadPointer.Transfer_Date__c = System.Now();
                    } else if (oldPointer.bdr_to_sr__c == True && leadPointer.bdr_to_sr__c == false) {
                        leadPointer.bdr_to_sr_rep__c = null;
                    }
                    if (leadPointer.bdr_to_ae__c == True){
                        leadPointer.bdr_to_ae_rep__c = UserInfo.getUserId();
                        leadPointer.Transfer_Date__c = System.Now();
                    } else if (oldPointer.bdr_to_ae__c == True && leadPointer.bdr_to_ae__c == false) {
                        leadPointer.bdr_to_ae_rep__c = null;
                    }
                    if (leadPointer.bdr_to_reseller__c == True){
                        leadPointer.bdr_to_reseller_rep__c = UserInfo.getUserId();
                        leadPointer.Transfer_Date__c = System.Now();
                    } else if (oldPointer.bdr_to_reseller__c == True && leadPointer.bdr_to_reseller__c == false) {
                        leadPointer.bdr_to_reseller_rep__c = null;
                    }
                    if (leadPointer.sr_to_ae__c == True){
                        leadPointer.sr_to_ae_rep__c = UserInfo.getUserId();
                        leadPointer.Transfer_Date__c = System.Now();
                    } else if (oldPointer.sr_to_ae__c == True && leadPointer.sr_to_ae__c == false) {
                        leadPointer.sr_to_ae_rep__c = null;
                    }
                    if (leadPointer.sr_to_reseller__c == True){
                        leadPointer.sr_to_reseller_rep__c = UserInfo.getUserId();
                        leadPointer.Transfer_Date__c = System.Now();
                    } else if (oldPointer.sr_to_reseller__c == True && leadPointer.sr_to_reseller__c == false){
                        leadPointer.sr_to_reseller_rep__c = null;
                    }
                    if (leadPointer.ae_to_reseller__c == True){
                        leadPointer.ae_to_reseller_rep__c = UserInfo.getUserId();
                        leadPointer.Transfer_Date__c = System.Now();
                    } else if (oldPointer.ae_to_reseller__c == True && leadPointer.sr_to_reseller__c == false) {
                        leadPointer.ae_to_reseller_rep__c = null;
                    }
                }
            }    
        }
    }
}

 

 

The Trigger is very simple so I don't understand where this is happening? Strange thing as well, if I load let's say 350 leads the first 200 will get this error and the next 150 will load fine. If I reduce that too 300 leads loaded the first 200 still error and the next 100 make it in just fine.

 

Any help is very appreciated thank you!

 

-Jon

  • September 10, 2013
  • Like
  • 0