Domanda

Sto scrivendo una classe di test per un trigger.Ma non sono in grado di eseguirlo correttamente, contiene solo il 68%. L'errore è

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, This part is not forecastable. 

@isTest
private class TestTriggers
{
   static testMethod void testService()
   {        
   //Insert part    
    list<Opportunity> Opportunity = new list<Opportunity>();
    Opportunity = [Select id from Opportunity];
    list<Product2> Product = new list<Product2>();
    Product = [Select id from Product2];
    Part__c p = new Part__c(Stage__c = 'idea',Product__c=Product[0].id,Opportunity__c=Opportunity[0].id);
    insert p;

   //Update part
    list<part__c> partlist = new list<part__c>();
    partlist =  [Select Stage__c from part__c where Stage__c = 'idea'];
    partlist[0].Stage__c = 'update';
    update partlist;/* */
   }
}

grazie Anuraj

È stato utile?

Soluzione

Esiste una regola di convalida sull'oggetto Part.Per visualizzare le regole di convalida, vai a Configurazione> Crea> Oggetti> Parte> Regole di convalida.

Sarà necessario modificare il codice per creare un record Part__c conforme alle regole di convalida.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top