我有一个简单的触发器,当我的自定义对象上的 SD_Action__c 字段为某个值时,它应该会创建一个新机会。代码没有错误,但是当我尝试更新沙盒或生产中的字段时没有任何反应。我错过了什么才能让这个伟大的机会成为什么时候m.SD_Action__c=='Generate Opportunity'
?
trigger MDwinning on MD_Meeting__c (after update) {
List <Opportunity> oppToInsert = new List <Opportunity> ();
for (MD_Meeting__c m : Trigger.new) {
if (m.SD_Action__c == 'Generate Opportunity') {
Opportunity o = new Opportunity ();
// o.Owner = m.Sales_Director__c,
o.Market_Developer__c = m.Market_Developer__c;
//o.Account = m.Account__c;
oppToInsert.add(o);
}//end if
}//end for o
try {
insert oppToInsert;
} catch (system.Dmlexception e) {
system.debug (e);
}
}
这是我的测试课:
@isTest (SeeAllData = true)
public with sharing class MDwinningTest {
static testMethod void MDwinningTest() {
MD_Meeting__c m = new MD_Meeting__c(
Account__c = 'test Account',
Desired_Meeting__c = 'Call',
Name = 'Meeting name',
Sales_Director__c = 'SD Name',
Market_Developer__c = 'MD Name',
Meeting_Date__c = Date.today(),
Contact__c = 'Test Contact',
Title__c = 'Boss',
Functional_Role__c = 'eCommerce - VP',
Contact_Email__c = 'test@aol.com',
SD_Action__c = 'Generate Opportunity',
Primary_URL__c = 'http://www.google.com/'
);
insert m;
}
}