FIELD_CUSTOM_VALIDATION_EXCEPTION

Anu*_*Anu 3 salesforce apex

我正在为触发器编写测试类.但我无法正常运行它只包含68%.错误是

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;/* */
   }
}
Run Code Online (Sandbox Code Playgroud)

谢谢Anuraj

Jer*_*oss 9

Part对象上有一个验证规则.要查看验证规则,请转至设置>创建>对象>部件>验证规则.

您需要修改代码以创建符合验证规则的Part__c记录.