• jdl2010
  • NEWBIE
  • 25 Points
  • Member since 2010

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

I wrote a trigger that is supposed to create records on a related object called Opportunity Heading every time a new Opportunity is created with the record type RPM.

 

When I don't specify the Opportunity record type in the trigger, it creates the records the way it should.  However, if a user creates a Opportunity of another record type, validation rules on those other record types cause system.dmlexception errors:

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Must select at least one product proposal type.: []

 

I only want this trigger to run if the opportunity created has a "RPM" recordtype, but when I add that to the trigger, it doesn't create the related list record.  Any ideas what I'm doing wrong?

Here is the trigger that creates the records (but need record type specified):

Trigger AddOppHdgtoRelatedList on Opportunity (after insert)

{    
    List<Opportunity_Headings__c> OHdg = new List<Opportunity_Headings__c>();    

   for (Opportunity O : Trigger.new)

  {             

  {   

  Opportunity_Headings__c OH = new Opportunity_Headings__c(Heading__c = O.Main_Heading__c,Opportunity__c = O.ID, Account__c = O.Accountid);           

  OHdg.add(OH);       

  }   

}     

if(OHdg.size() > 0)   

  insert OHdg;

}

Here is the trigger with record type specified that does not work:

Trigger AddOppHdgtoRelatedList on Opportunity (after insert)

{    
  List<RecordType> OpprtID = [Select Id From RecordType 
  where sObjectType='Opportunity' and Name='RPM'];  
    
  Set<RecordType> s=new Set<RecordType>();
  s.addAll(OpprtId);
  
  List<Opportunity> Opps = new List<Opportunity>();
   
  List<Opportunity_Headings__c> OHdg = new List<Opportunity_Headings__c>();    

   for (Opportunity O : Trigger.new)

  {   

   If (s.contains(o.RecordType))             

  {   

  Opportunity_Headings__c OH = new Opportunity_Headings__c(Heading__c = O.Main_Heading__c,Opportunity__c = O.ID, Account__c = O.Accountid);           

  OHdg.add(OH);       

  }   

}     

if(OHdg.size() > 0)   

  insert OHdg;

}

Hi there!

 

I wondering what the apexp extension means.

I have seen some apps referring to an unknown URL. For example:

 

https://na?.salesforce.com/nexpath/nexpathmembers.apexp?id=a0?A0000002abc1&retURL=/a0?A0000002abc1

 

What is nexpath? A namespace prefix?

What is nexpathmembers.apexp? I don't see any VF page with that name. In fact, there is no VF at all.

 

Thanks, JDL

Hi there!

 

I wondering what the apexp extension means.

I have seen some apps referring to an unknown URL. For example:

 

https://na?.salesforce.com/nexpath/nexpathmembers.apexp?id=a0?A0000002abc1&retURL=/a0?A0000002abc1

 

What is nexpath? A namespace prefix?

What is nexpathmembers.apexp? I don't see any VF page with that name. In fact, there is no VF at all.

 

Thanks, JDL

Hi there!

 

I wondering what the apexp extension means.

I have seen some apps referring to an unknown URL. For example:

 

https://na?.salesforce.com/nexpath/nexpathmembers.apexp?id=a0?A0000002abc1&retURL=/a0?A0000002abc1

 

What is nexpath? A namespace prefix?

What is nexpathmembers.apexp? I don't see any VF page with that name. In fact, there is no VF at all.

 

Thanks, JDL

I have a Apex Test Class that has been running fine.  I just trying to deploy a new trigger in my production org on the same object and it caused an error in the test class.



Failure Message: "System.LimitException: Too many SOQL queries: 21", Failure Stack Trace: "Class.ContractTestFactory.ContractsonAccount: line 21, column 27 External entry point"



Here is my test class:


@isTest
private class ContractTestFactory{
  private static TestMethod void ContractsonAccount()
    {    
    test.startTest(); 
      
    Account myAccount=new Account(name='testacct10',recordtypeid='01270000000Dvnf',
    lead_converted_date__c=date.today());
    insert(myAccount);
    
    Contract myContract = new Contract(recordtypeid='01270000000DwX4',
            accountid=myAccount.id,StartDate=date.today());
    insert(myContract);
    
    myContract.RPM_Signed_Contract__c=1;
    update(myContract);
    
    //List<Account> insertedAccounts = [SELECT Name, RPM_Signed_Contracts__c 
                                      //FROM Account];
    
    List<Account> accts = [SELECT id, name FROM account
                            WHERE name='testacct10'];
                            

    System.assertEquals(null,myAccount.RPM_Signed_Contracts__c);   
    test.stopTest();  
    }

Any ideas why I might be getting this message now?

I wrote a trigger that is supposed to create records on a related object called Opportunity Heading every time a new Opportunity is created with the record type RPM.

 

When I don't specify the Opportunity record type in the trigger, it creates the records the way it should.  However, if a user creates a Opportunity of another record type, validation rules on those other record types cause system.dmlexception errors:

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Must select at least one product proposal type.: []

 

I only want this trigger to run if the opportunity created has a "RPM" recordtype, but when I add that to the trigger, it doesn't create the related list record.  Any ideas what I'm doing wrong?

Here is the trigger that creates the records (but need record type specified):

Trigger AddOppHdgtoRelatedList on Opportunity (after insert)

{    
    List<Opportunity_Headings__c> OHdg = new List<Opportunity_Headings__c>();    

   for (Opportunity O : Trigger.new)

  {             

  {   

  Opportunity_Headings__c OH = new Opportunity_Headings__c(Heading__c = O.Main_Heading__c,Opportunity__c = O.ID, Account__c = O.Accountid);           

  OHdg.add(OH);       

  }   

}     

if(OHdg.size() > 0)   

  insert OHdg;

}

Here is the trigger with record type specified that does not work:

Trigger AddOppHdgtoRelatedList on Opportunity (after insert)

{    
  List<RecordType> OpprtID = [Select Id From RecordType 
  where sObjectType='Opportunity' and Name='RPM'];  
    
  Set<RecordType> s=new Set<RecordType>();
  s.addAll(OpprtId);
  
  List<Opportunity> Opps = new List<Opportunity>();
   
  List<Opportunity_Headings__c> OHdg = new List<Opportunity_Headings__c>();    

   for (Opportunity O : Trigger.new)

  {   

   If (s.contains(o.RecordType))             

  {   

  Opportunity_Headings__c OH = new Opportunity_Headings__c(Heading__c = O.Main_Heading__c,Opportunity__c = O.ID, Account__c = O.Accountid);           

  OHdg.add(OH);       

  }   

}     

if(OHdg.size() > 0)   

  insert OHdg;

}