【发布时间】:2017-02-16 15:23:09
【问题描述】:
我在 71%,4 行代码由于某种原因无法在测试中运行。 当我在 Salesforce 中测试自己时,它可以工作(那些代码行正在运行)。 如何让这些代码行在测试中运行?
行未运行,在第二个 for 循环中 nextId=Integer.Valueof(c.next_id__c);
-
行未运行,在第三个 for 循环中 btnRecord.next_id__c = newid + 1; btnRecord.last_id__c = newId;
btnRecord.last_assigned_starting_id__c = nextId; btnRecord.last_assigned_ending_id__c = newId;
下面是我的代码:
trigger getNextId on tracking__c (before insert, before update) {
Integer newId;
Integer lastId;
Integer nextId;
newId=0;
lastId=0;
nextId =0;
//add the total accounts to the last_id
for (tracking__c bt: Trigger.new) {
//get the next id
List<tracking_next_id__c> btnxtid = [SELECT next_id__c FROM tracking_next_id__c];
for (tracking_next_id__c c : btnxtid )
{
nextId=Integer.Valueof(c.next_id__c);
}
newId = Integer.Valueof(bt.total_account__c) + nextId;
bt.starting_id__c = nextId;
bt.ending_id__c = newId;
tracking_next_id__c[] nextIdToUpdate = [SELECT last_id__c, next_id__c, last_assigned_starting_id__c, last_assigned_ending_id__c FROM tracking_next_id__c];
for(tracking_next_id__c btnRecord : nextIdToUpdate ){
btnRecord.next_id__c = newid + 1;
btnRecord.last_id__c = newId;
btnRecord.last_assigned_starting_id__c = nextId;
btnRecord.last_assigned_ending_id__c = newId;
}
update nextIdToUpdate ;
}
}
【问题讨论】:
标签: salesforce