function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
s5s5 

error in trigger

Hi Team,

 

I wrote one trigger to get account name where record type ='web to lead type'  from account object and insert account name in qualification object where record type for this object is 'Material' to create new record for this record type in qualification object.But it is showing error.Please help me in this.The below is the Programme i wrote and error message is also shown below.

 

trigger TogetQualificationdetails on Account (after insert) {

    List<Qualification__c> qual=new Qualification__c[0];
    Qualification__c qualify=new Qualification__c();
    for(Account acc:trigger.new){
        //Account a= System.Trigger.NewMap.get(acc.id);
        //System.debug('id'+a);

        RecordType record=[select id,name from RecordType where Name='web to lead type'];
        //if(acc.RecordType == 'Web to lead type'){
        qual.add(new Qualification__c(Account__c=acc.Name,recordtypeid=record.id,id=acc.id));
       // }
        system.debug('details'+qual);
      
      
    }
    insert qual;

}

 

The error message is as follows

 

03:18:51.057 (1057061000)|CODE_UNIT_STARTED|[EXTERNAL]|01qQ00000004bfq|TogetQualificationdetails on Account trigger event AfterInsert for [001Q000000OvpqZ]
03:18:51.057 (1057857000)|SOQL_EXECUTE_BEGIN|[9]|Aggregations:0|select id,name from RecordType where Name='web to lead type'
03:18:51.063 (1063990000)|SOQL_EXECUTE_END|[9]|Rows:0
03:18:51.064 (1064136000)|EXCEPTION_THROWN|[9]|System.QueryException: List has no rows for assignment to SObject
03:18:51.064 (1064233000)|FATAL_ERROR|System.QueryException: List has no rows for assignment to SObject

Trigger.TogetQualificationdetails: line 9, column 27
03:18:51.833 (1064308000)|CUMULATIVE_LIMIT_USAGE
03:18:51.833|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 1 out of 100
Number of query rows: 0 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Number of script statements: 3 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

03:18:51.833 (1064308000)|CUMULATIVE_LIMIT_USAGE_END

03:18:51.064 (1064456000)|CODE_UNIT_FINISHED|TogetQualificationdetails on Account trigger event AfterInsert for [001Q000000OvpqZ]
03:18:51.064 (1064488000)|EXECUTION_FINISHED

 

 

Please help me how to write the trigger for this condition.The one i wrote is showing error.

 

Thanks in advance

srikeerthisrikeerthi

Hi

 

Modify the query in this way

Recordtype[] re=[select id,name from recordtype where sobjecttype='Account' and name='Web_to_lead_type'];

 

 

Thanks