web
You’re offline. This is a read only version of the page.
close
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 224

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

I have the same question (0)
  • Suggested answer
    Temmy Wahyu Raharjo Profile Picture
    2,916 on at

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans