• l00p3y
  • NEWBIE
  • 0 Points
  • Member since 2006

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 7
    Replies

I am receiving DML error "cannot_insert_update_activate_entity, CreateAssetonClosedWon Line 43 of testCreateAssetonClosedWon execution of BeforeUpdate" I thought the record was locked but I get the same error attempting to use AfterUpdate as well.

 

Test Class

@isTest 

private class testCreateAssetonClosedWon {
    
    static testMethod void testCreateAssetonClosedWon(){
    	System.debug('Alerting on --------> Starting the TestCreateAssetonClosedWon ');
        List<OpportunityLineItem> insertOl = new List<OpportunityLineItem>{};
        Account a = [select Id from Account limit 1];
        System.debug('Alerting on --------> Account a -'+a);
        PricebookEntry pbID = [select Id from PricebookEntry where isactive = true limit 1];
        System.debug('Alerting on --------> PricebookEntry a -'+pbID);
        List<Opportunity> opp = new List<Opportunity>{};
        
        for(Integer i=0;i<200;i++){
        	Opportunity o = new Opportunity();
        	o.AccountId = a.Id;
        	o.Name = 'test';
        	o.StageName = '0-Prospecting';
        	o.CloseDate = date.today();
        	opp.add(o);
       
        }
        	insert opp;
        	System.debug('Alerting on --------> Opportunity opp insert');
        	
        	for(Integer j=0;j<opp.size();j++){
        		OpportunityLineItem ol = new OpportunityLineItem();

			      	ol.OpportunityId = opp[j].Id;
      				ol.Quantity = 1;
       				ol.UnitPrice = 2.00;
	        		ol.PricebookEntryId = pbId.Id;
	        		insertOl.add(ol); 
        	}
        		insert insertOl;
        		System.debug('Alerting on --------> LineItem ol insert '+insertOl);
        	
        	for(Integer ou=0;ou <opp.size();ou++){
        		opp[ou].StageName = '8-Closed';
        		System.debug('Alerting on --------> Opportunity Stagel opp '+opp[ou].StageName+' - '+opp[ou].ID);
        	}
        	Test.startTest();
        	update opp;
        	Test.stopTest();

        
        //o.AccountId = a.Id;
        //o.Name = 'test';
        //o.StageName = '0-Prospecting';
        //o.CloseDate = date.today();
        //insert o;
        
//        ol.OpportunityId = o.Id;
//        ol.Quantity = 1;
//        ol.UnitPrice = 2.00;
//        ol.PricebookEntryId = pbId.Id;
        
//        insert ol;
        
//        o.StageName= '8-Closed';
//        update o;
        
       // delete ol;
        //delete o;
        
        
        
    }
    
    
}

 

Trigger:

trigger CreateAssetonClosedWon on Opportunity (after update) {
     Set<id> opSet = new Set<id>(); 
     for(Opportunity o:Trigger.new)
     	opSet.add(o.id); 
     	System.debug('Alerting on --------> Starting the CreateAssetonClosedWon Trigger');
     	Map<id, OpportunityLineItem> owners = new Map<id, OpportunityLineItem>([Select UnitPrice, Quantity, PricebookEntry.Product2Id, PricebookEntry.Product2.Name, Description, Converted_to_Asset__c  
                                      From OpportunityLineItem 
                                      where OpportunityId in :opSet  and Converted_to_Asset__c = false]);     	
     
 
     for(Opportunity o:Trigger.new)
      //if(o.isWon == true && o.HasOpportunityLineItem == true){
      if(Trigger.isUpdate){
      	if(o.stageName == '8-Closed' && o.HasOpportunityLineItem == true){
         Asset[] ast = new Asset[]{};
         Asset a = new Asset();
     //    for(OpportunityLineItem ol: OLI){
            a = new Asset();
            a.AccountId = o.AccountId;
            a.Product2Id = owners.get(o.Id).PricebookEntry.Product2Id; 
            a.Quantity = owners.get(o.Id).Quantity;
            a.Price =  owners.get(o.Id).UnitPrice;
            a.PurchaseDate = o.CloseDate;
            a.Status = 'Purchased';
            a.Description = owners.get(o.Id).Description;
            a.Name = owners.get(o.Id).PricebookEntry.Product2.Name;
            ast.add(a);
            owners.get(o.Id).Converted_to_Asset__c = true;
     //  }
      update owners.get(o.id); 
      insert ast;
     	}
      }
	}

 

I amattempting to build a custom controller that created two collections for Opportunity and a custom object named StateCoverageScript.  I have a problem within the retrun on line 10 column 8that states "expecting "set", found 'List'. I am not sure about the error so any assistance would be ahuge help....

 

 

 

 

public class opportunityStateCovCon { public ApexPages.StandardSetController setCon { get { if(setCon == null) { setCon = new ApexPages.StandardSetController(Database.getQueryLocator([select op.OwnerId,op.name,op.closedate,op.StageName, op.State__c from Opportunity op where op.State__c = :ApexPages.currentPage().getParameters().get('state') and op.INPUT_Opportunity_ID__c != NULL]));} return setCon; set; } public List<Opportunity> getOpportunities() { return (List<Opportunity>) setCon.getRecords(); } public ApexPages.StandardSetController setStateCoverage { get { if(setStateCoverage == null) { setStateCoverage = new ApexPages.StandardSetController(Database.getQueryLocator([select scs.name,scs.StateAbbreviation__c,scs.Deployment_Manager__c,scs.Government_Program_Manager__c from setStateCoverageScript__c scs where scs.StateAbbreviation__c = :ApexPages.currentPage().getParameters().get('state')]));} return setStateCoverage; } set; } public List<StateCoverageScript__c> getStateCoverage() { return (List<StateCoverageScript__c>) setStateCoverage.getRecords(); } }

 

 

 

  • April 30, 2009
  • Like
  • 0

I have a custom object(CO) that I would like to "Enhance" the detail page.  I would ike to build a custom controller that would query opportunities and list them via dataTable on the CO detail page.....  I have found nothing about maniulating the Detail page from the Cookbook, Developer Guide, or Visual Force guide.  I post the question to you guys, what am I overlooking?

 

  • April 29, 2009
  • Like
  • 0

I am attempting to create a custom class that I can call from a Trigger.  I am getting the error stated above but I am not quite understanding the dilemma... Any assistance would very useful....

 

 

public class StateCoverage { public static void coverage(StateCoverageScript__c[] scs){ scs.Total_Accounts__c = [Select count() From Account a where a.BillingState = : scs.StateAbbreviation__c ]; scs.Run_Script__c = false; scs.Last_Run_Date__c = system.today(); } }

 

 

 

 

 

  • April 20, 2009
  • Like
  • 0

I want to run a SOQL query and pass the results into a specific cooridinate of an Image Map. Similar to a tooltip or the title attribute.

 

Is this possible and if so where should I be looking?

 

 

ex:

 

List<Account> aa = [Select count() From Account a where a.BillingState = 'FL']

<LI><apex:outputLink shape="poly" coords="458,396,465,385,485,385,529,383,552,421,563,449,562,468,554,476,529,451,522,427,514,405,501,394" value="http://www.availity.com" title="Florida"></apex:outputlink></LI>

</Account>

 

  • April 15, 2009
  • Like
  • 0
I have created an S-Control to create a Case from an Opportunity.  The S-Control captures fields from the Opp and autopopulates fields I have mapped within Case via URL FOR.  I have a custom field named Case.Implementation_Name that I want to map to the Opportunity.Name field.  The Form name of the Case is "00NS0000000FtGi".  I am unable to get the Case.Implementation_Name field to populate.  I am using the Ajax Eclipse plugin and when I attempt to use the <label for="00NS0000000FtGi"> the error states "Field integrity exception occured, check your merge field definitions." when I attempt to use the merge field name I dont receive an error but the field still isnt populated.  Has anyone else had to overcome this problem, and how was it accomplished?

  • October 19, 2007
  • Like
  • 0
Is anyone familiar with the limitations of the Sandbox?  I have atttempted to upload 2076 records into our sandbox that are for 3 objects in Salesforce (Account Identifiers, Contracts, and Assets).  Out of the total 2076 records only 130 records are uploaded into each object with no errors thrown.
  • April 11, 2007
  • Like
  • 0
Is it possible, once criteria has been met for a picklist field, that variable will not change?
 
 
We currently have a custom field labeled {Account Status} that is a picklist on the page layout of the Account object. Once the selection of Live has been selected as the {Account Status}, I want the field to always remain Live. 
 
-  I can not set validation rules that might throw an error msg. ( we have a lot of code that would need to be changed to handle the exception)
 
- I  can not set the field to Read-Only because of an error (see above)
 
 
Does anyone have any ideas?  I would greatly appreciate it.
  • March 06, 2007
  • Like
  • 0
Has anyone else noticed any problem reporting on case comments since the 07 Release? 
 
1. When you delete a comment it still shows up on a report.
 
2. We are unable to pull reports by comments created date or last modified. The reports are skewed.
 
 
  • February 07, 2007
  • Like
  • 0

I amattempting to build a custom controller that created two collections for Opportunity and a custom object named StateCoverageScript.  I have a problem within the retrun on line 10 column 8that states "expecting "set", found 'List'. I am not sure about the error so any assistance would be ahuge help....

 

 

 

 

public class opportunityStateCovCon { public ApexPages.StandardSetController setCon { get { if(setCon == null) { setCon = new ApexPages.StandardSetController(Database.getQueryLocator([select op.OwnerId,op.name,op.closedate,op.StageName, op.State__c from Opportunity op where op.State__c = :ApexPages.currentPage().getParameters().get('state') and op.INPUT_Opportunity_ID__c != NULL]));} return setCon; set; } public List<Opportunity> getOpportunities() { return (List<Opportunity>) setCon.getRecords(); } public ApexPages.StandardSetController setStateCoverage { get { if(setStateCoverage == null) { setStateCoverage = new ApexPages.StandardSetController(Database.getQueryLocator([select scs.name,scs.StateAbbreviation__c,scs.Deployment_Manager__c,scs.Government_Program_Manager__c from setStateCoverageScript__c scs where scs.StateAbbreviation__c = :ApexPages.currentPage().getParameters().get('state')]));} return setStateCoverage; } set; } public List<StateCoverageScript__c> getStateCoverage() { return (List<StateCoverageScript__c>) setStateCoverage.getRecords(); } }

 

 

 

  • April 30, 2009
  • Like
  • 0

I have a custom object(CO) that I would like to "Enhance" the detail page.  I would ike to build a custom controller that would query opportunities and list them via dataTable on the CO detail page.....  I have found nothing about maniulating the Detail page from the Cookbook, Developer Guide, or Visual Force guide.  I post the question to you guys, what am I overlooking?

 

  • April 29, 2009
  • Like
  • 0

My client

 

Wants to be able to send automated reports onto multiple email recipients.

 

The problem we have at the moment is this automated trigger can be setup but it will only allow them to email actual licenced users that have been setup on SF.

 

Whats the solution to this?

I have created an S-Control to create a Case from an Opportunity.  The S-Control captures fields from the Opp and autopopulates fields I have mapped within Case via URL FOR.  I have a custom field named Case.Implementation_Name that I want to map to the Opportunity.Name field.  The Form name of the Case is "00NS0000000FtGi".  I am unable to get the Case.Implementation_Name field to populate.  I am using the Ajax Eclipse plugin and when I attempt to use the <label for="00NS0000000FtGi"> the error states "Field integrity exception occured, check your merge field definitions." when I attempt to use the merge field name I dont receive an error but the field still isnt populated.  Has anyone else had to overcome this problem, and how was it accomplished?

  • October 19, 2007
  • Like
  • 0