【问题标题】:For Loop runs one extra time than the length specifiedFor 循环比指定的长度多运行一次
【发布时间】:2015-06-12 09:49:53
【问题描述】:

在 Dynamics CRM 中,我在自定义活动实体中使用 javascript 来创建电话呼叫。以下是运行以创建电话呼叫的 for 循环。

for (var indxAttendees = 0; indxAttendees < respondent.length; indxAttendees++) {
        //List of parameters for phone call

    XrmServiceToolkit.Soap.Create(createPhCall);
}

但它比指定的长度多运行一倍,并且还会产生额外的电话 我需要您的帮助来解决问题

【问题讨论】:

    标签: javascript microsoft-dynamics phone-call


    【解决方案1】:

    我在控制台中尝试了以下代码:

    var respodent = ["a","b","c"]; 
    for (var indxAttendees = 0; indxAttendees < respondent.length; indxAttendees++) {
                //List of parameters for phone call
    
           console.log(indxAttendees);
        }
    

    输出是:

    0
    1
    2
    

    所以正确检查respodent长度,我认为没有任何问题。

    【讨论】:

    • 也许您应该将您的受访者命名为 a、b、c 以避免将它们与从 0 到 2 的索引混淆。
    • 我已经通过调试器进行了检查。它运行等于指定的长度,但在短时间间隔后创建了额外的记录。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-04
    • 1970-01-01
    • 2020-07-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多