gpt4 book ai didi

salesforce - FIELD_CUSTOM_VALIDATION_EXCEPTION

转载 作者:行者123 更新时间:2023-12-04 12:15:43 27 4
gpt4 key购买 nike

我正在为触发器编写测试类。但我无法正确运行它,它只包含 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;/* */
}
}

谢谢
阿努拉杰

最佳答案

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

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

关于salesforce - FIELD_CUSTOM_VALIDATION_EXCEPTION,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8403773/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com