Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to the total length of the value from an array

(0) ShareShare
ReportReport
Posted on by 220

Hi Experts

Sorry i dont know how to construct my question. My goal is i want to get all of the length from an array and here's my code

personEmails.forEach(function(test){
var b = test.IncidentId;
var $sentEmails= cbs.CaseDocuments.getSentEmails(personId, b);
$.when($sentEmails).then(function (sentEmails) {
test = sentEmails.length;
return test++;
});
});

on my "personEmails" there are two value and i get the incidentId to get the list of sent emails, on the first loop and goes to the getPersonEmails the "length is two" and on the second loop it get only one value/length and the result is 2 instead of 3, because on the first loop the 2 value/length it counts only as one on the return test.

Do you have any idea about this? i really need you help and im not good on Javascript thanks in advance

*This post is locked for comments

  • Suggested answer
    Temmy Wahyu Raharjo Profile Picture
    Temmy Wahyu Raharjo 2,914 on at
    RE: How to the total length of the value from an array

    var result = 0;

    personEmails.forEach(function(test){

    var b = test.IncidentId;

    var $sentEmails= cbs.CaseDocuments.getSentEmails(personId, b);

    $.when($sentEmails).then(function (sentEmails) {

    test = sentEmails.length;

    result+= test;

    return test++;

    });

    });

    Then if you want to get the total, you just need to get from result variable.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,489 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans