0

I wrote this trigger:

trigger  newTrigger on Task (before insert, before update) {
    Id standardTaskRTId = Task.SObjectType.getDescribe().getRecordTypeInfosByName().get('Standard Task').getRecordTypeId();
    for(Task record: Trigger.new) {
        if(record.RecordTypeId == standardTaskRTId && record.Description.Length()>=255) {
            record.CommentShort__c = record.Description.substring(0,255);
        }else{
            record.CommentShort__c = record.Description;
        }
    }
}

and now i want to test this trigger and i created a test class:

@isTest 
private class newTriggerTest {
static testMethod void checkTriggerMethod() {
   Account acc = new Account();
   acc.CustomerMainType__c = 'Individual';
   acc.CustomerType__c = 'Detail Customer';
   acc.Salutation = 'ANKEI';
   acc.FirstName = 'Test';
   acc.LastName = 'Test01';
   acc.AdditionalAddressState__c = 'DE';
   acc.AdditionalAddressPostalCode__c = '3400';
   acc.AdditionalAddressCity__c = 'Munchen';
   acc.AdditionalAddressStreet__c= 'Albac';
   acc.AdditionalAddressStreetNumber__c='123';

   insert acc;

   Task tsk = new Task();
   tsk.OwnerId='Cristian Trif';
   tsk.Subject ='Activity';
   tsk.ActivityDate = system.today();
   tsk.Status = 'Completed';
   tsk.Priority ='Normal';
   tsk.WhatId = acc.id;

   insert tsk;     

   // Retrieve the task
  Task tskNew = [SELECT Description, CommentShort__c FROM Task WHERE Id =:tsk.Id];

}}

But I'm not sure why I have this error when i run the test class:

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, The chosen combination of Maintype/Type/Specialtype is not possible - please check: RSP CRM | Individual | Detail Customer: []

What I did wrong here?

1 Answer 1

1

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, The chosen combination of Maintype/Type/Specialtype is not possible - please check: RSP CRM | Individual | Detail Customer: []

Your Run Test is getting failed because of Validation Exception with is they in your Org. Please make that validation field true in Test Class. for finding that validation rule. see the error message you got.

FIELD_CUSTOM_VALIDATION_EXCEPTION, The chosen combination of Maintype/Type/Specialtype is not possible - please check: RSP CRM

Thanks

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .