For Loop runs one extra time than the length specified

451 views Asked by At

In Dynamics CRM, I'm using javascript at custom activity entity to create the phone calls. following is the for loop that runs to create the phone calls.

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

    XrmServiceToolkit.Soap.Create(createPhCall);
}

But it runs one extra times than the length specified and also create an extra phone call I need your help to resolve the issue

1

There are 1 answers

2
Nikhil Batra On

I tried the following code in the console :

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

       console.log(indxAttendees);
    }

and output is:

0
1
2

So check respodent length properly, I don't think there is any issue.