• APEX 123
  • NEWBIE
  • -1 Points
  • Member since 2013

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

à is changing to Ã .i have every canging html code binary code.can any say solution fro this

Developer script exception from Nicomatic : quotepotential : quotepotential: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a0Q90000005Q9RWEA0; first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record: [] Trigger.quotepotential: line 17, column 1


caused by: System.DmlException: Update failed. First exception on row 0 with id a0Q90000005Q9RWEA0; first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record: []

Trigger.quotepotential: line 17, column 1

 

 

this is my Trigger:

 

trigger quotepotential on Quote_Line_Item__c (after insert,after update) {
    Set<Id> quoteIds = new Set<Id>();
    List<Quote__c> quotes = new List<Quote__c>();
    for(Quote_Line_Item__c record: Trigger.new) {
    if (record.Quote1__c != null){
        quoteIds.add(record.Quote1__c);
    }
    }
    for(AggregateResult ar:[SELECT Quote1__c , SUM(Max_Batch__c)sumMax FROM Quote_Line_Item__c WHERE Quote1__c IN :quoteIds GROUP BY Quote1__c]) {
      Quote__C qu=new quote__c();
      qu.id=(Id)ar.get('Quote1__c');
      qu.Potential__c=(Decimal)ar.get('sumMax');
       quotes.add(qu);
}
if(quotes.isempty() == false)
    {
  update quotes;
  }
}
we have one more button in quote email template at the time click this button i am getting exception to my mail.

the function of quote email template it will send the quote pdf into email which sending to other user

Hello all,

 

@future's seem to cause a lot of fun and games, but this one has me foxed. I'm sure someone has solved this one.

I have a trigger on a case change. (Some pretty wierd code in here = legacy)

 

 

trigger caseChangeTrigger onCase (beforeinsert, beforeupdate) {

 

 Set<Id> ownerIds = new Set<Id>(); 

 Map<Id,Id> map1 = new Map<Id,Id>();

 Map<Id,boolean> map2 = new Map<Id,boolean>();

 Map<Id,Id> map3 = new Map<Id,Id>();

 

    Case[] cs = trigger.new;

    for (Case c : cs) 

    {

        ownerIds.add(c.OwnerId); 

        map1.put(c.Id,c.OwnerId);

    }

    

    for(User u : [select Id, Out_Of_Office__c, User_Backup__c from User where Id in : ownerIds])

    {

        map2.put(u.Id,u.Out_Of_Office__c);

        map3.put(u.Id,u.User_Backup__c);

    }

    

    for(Case c : cs)

    {

        if (map2.get(map1.get(c.Id)) == true ) { 

            c.Case_Owner_Backup__c = map3.get(map1.get(c.Id));

        } 

        else {

            c.Case_Owner_Backup__c = null;

        }

            

      if(c.accountid==null && c.RecordTypeId=='012500000001BVb')

      {

        c.accountid = '0015000000PJ7ec';

      }   

      

      // Sync Case with JIRA Issues

      String systemId = '1';

      String objectType ='CASE';

      String objectId = c.id;

      //Execute the sync

      JIRAConnectorWebserviceCallout.syncCase(jiraURL, systemId ,objectType,objectId);      

    } 

}

 

It's that final block that causes all the problems. 

and that syncCase does a call to a remote system. (Pretty common thing to do, I've noticed.) It begins...

 

global class JIRAConnectorWebserviceCallout {

    @future (callout=true)

    WebService static void syncCase(String jiraURL, String systemId, String objectType, String objectId) {

.... etc,

 

 

And the error is:

 

caseChangeTrigger: execution of BeforeUpdate

 caused by: System.AsyncException: Future method cannot be called from a future or batch method: JIRAConnectorWebserviceCallout.syncCase(String, String, String, String)

 

I've seen cases where a @future is called within a trigger, and the trigger shouldn't be firing multiple times, since I don't have any batch scripts running.

 

I'd appreciate any ideas and recommendations,

Thanks,

Graeme

 

  • June 20, 2012
  • Like
  • 0

I am recieving the following error when I try to deploy my apex class and test class: visualforce CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, opptySwarm: execution of AfterUpdate.  Is this because I am trying to update too many field at once?? Or some other issue? What is my best option to fix this?

 

Thank you in advance, I am new to Salesforce development.

 

Chris


Apex Class:

 

 

global class OppPoliceController {
 
  public void Opportunity1() {
  	
  	 List<Opportunity> Opptys2 = [SELECT CreatedDate, StageName, LastActivityDate, Activity_Status__c, (SELECT CreatedDate FROM Feeds ORDER BY CreatedDate DESC limit 1), (SELECT Status FROM Tasks) FROM Opportunity WHERE StageName != 'Closed Won' AND StageName != 'Closed Lost' AND StageName != 'Closed Other' AND StageName != 'Qualified Lost' AND StageName != 'Prospect' AND CloseDate != Today ORDER BY LastActivityDate DESC];
 
	
        for(Opportunity Op : Opptys2){
        
        datetime d = Date.today();  //Current Date Formated
        datetime LastActivityDate = Op.LastActivityDate; //Last Activity Date in datetimeformat
        
        datetime CreatedDate1;
        if(Op.Feeds != Null && !Op.Feeds.isEmpty()) {
        	
           CreatedDate1 = Op.Feeds[0].CreatedDate;  //Created Date in datetime format 	
          
        }
        else {
        	system.debug('<--------------Error CreatedDate for Feeds is Null---------------->');
        	CreatedDate1 = Op.CreatedDate;
        	
        }
         	 
        string Status1;
        if(Op.Tasks != Null && !Op.Tasks.isEmpty())  {
        	
        	Status1 = Op.Tasks[0].Status;
        	
        }
        else {
        	system.debug('<----------------ERROR Staus for Tasks is Null-------------------->');
        	Status1 = null;
        	
        }
        

        System.debug('This is the created date: ' + CreatedDate1);
        System.debug('This is the status: ' + Status1);
        System.debug('This is todays date: ' + d); 
        
            if(LastActivityDate == Null) { 
            	
            	if(Status1 == 'In Progress' || Status1 == 'Waiting on someone else' || Status1 == 'Deferred') {
            		
            		 Op.Activity_Status__c = 'Low'; 
            		 	 
            	}
            	 else if(Status1 == null || Status1 == 'Not Started' || d > CreatedDate1.addDays(14)) {
            	
            	 Op.Activity_Status__c = 'High'; 
            	     	 
            	}
            	 else if(d >= CreatedDate1.addDays(7) && d < CreatedDate1.addDays(14)) {
         
                 Op.Activity_Status__c = 'Medium'; 
               
                  }
                  else {
                  	
                  	 Op.Activity_Status__c = 'error';  
                  }
                          	
            }
           
            else if(d > LastActivityDate.addDays(14) || d > CreatedDate1.addDays(14)) {
              
              Op.Activity_Status__c = 'High';
              
            }
            
            else if((d >= CreatedDate1.addDays(7) && d < CreatedDate1.addDays(14))
            	|| (d >= LastActivityDate.addDays(7) && d < LastActivityDate.addDays(14)) ) {
         
               Op.Activity_Status__c = 'Medium'; 
               
            }
              
            else if(d < LastActivityDate.addDays(7) || d < CreatedDate1.addDays(7) || Status1 == 'In Progress' || Status1 == 'Waiting on someone else' || Status1 == 'Deferred') {
            	
                Op.Activity_Status__c = 'Low';
                
            }
            	
            else {
            
                Op.Activity_Status__c = 'Error';
                   
            }
        }    
           update Opptys2;
  
  }   
}

 

 

 

Apex Test Class

 

 

@isTest
private class OppPoliceTestClass {

    static testMethod void testOpportunity1() {
        
      date d = Date.today() + 7;
      
      System.debug('The close date is: ' + d);
        
      Opportunity Opp = new Opportunity();
      Opp.name = 'Op-Test9';
      Opp.StageName = 'Open';
      Opp.CloseDate = d;
   
      insert Opp;
      
      Task t = new Task();
      t.Subject='Send out Notice';
      t.Status = 'Not Started';
      t.Priority = 'Normal';
      t.WhatId = Opp.id;
      
      insert t;
      
      System.debug('This is the Opp id: ' + Opp.id);
      System.debug('This is the WhatId: ' + t.WhatId);
      
      OppPoliceController myClass = new OppPoliceController();
      myClass.Opportunity1();
      
      List<Opportunity> OppStatus = [select o.name, o.Activity_Status__c from Opportunity o WHERE o.name= 'Op-Test9' LIMIT 1];
      
      string OpName = OppStatus[0].name;
      System.debug('The name of the Opp is ' + OpName);    
      
      for(Opportunity Op2 : OppStatus){
          
          System.assertEquals('High',Op2.Activity_Status__c);
          System.debug('The Activity Status for the Test is: ' + Op2.Activity_Status__c);
          
      }                              
   }
}



 

 

 

 

I'm trying to write test cases for my APEX code.I searched  the Apex documentation and  the Apex discussion board but did not find solution. I am getting two errors. I tried  but unfortunately not getting the required output. Let me know where i am getting error.  I had written the same code in the trigger without using Apex class it was working perfect. But since i need to deploy the trigger i started writing Apex class which gives me these errors.
Thanks in advance for the solution.
 
 
This is what i am trying to accomplish.
 
When ever a new custom object(Client)  is created or updated i need to update few fields accordingly.
 
 
And the errors are at line 35 and 54
 
Errrors
1)  System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ClientUpdates: execution of AfterInsert
caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.
Even if a field is indexed a filter might still not be selective when:
1. The filter value includes null (for instance binding with a list that contains null)
2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times)
Class.ClientApex.afterinsertupdate: line 69, column 1
Trigger.ClientUpdates: line 19, column 1
 
2)  System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ClientUpdates: execution of AfterInsert
caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.
Even if a field is indexed a filter might still not be selective when:
1. The filter value includes null (for instance binding with a list that contains null)
2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times)
Class.ClientApex.afterinsertupdate: line 69, column 1
Trigger.ClientUpdates: line 19, column 1
 
 


Message Edited by renu on 07-09-2008 02:20 PM
  • July 09, 2008
  • Like
  • 1