Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Issue With the Javascript Arrays

Posted on 2014-11-12
3
Medium Priority
?
128 Views
Last Modified: 2014-11-16
Hi,

I have attached the script. What I am trying to do is specified in the comments in the script.

Below are the comments that I specified in the script.

     //check if the pre-built  dashboard items array has a projectdesc that matches the projectName and then build the table row by passing Project Name and projectURL, projectstatuslabel to the getProjectRow function

//Here how do I iterate through dashboard items array to check if there is a matching projectdesc whose string value is equal to ProjectName inside this for loop?

i need to iterate through the dashboard array and find a matching description of the value in the for loop and then get the remaining properties of the object.

Please let me know if this is not clear.
script-2.txt
script-2.txt
0
Comment
Question by:Techsavy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
vr6r earned 2000 total points
ID: 40438327
Updated and commented the For loop from your script, give this a try:

for (var i = 0; i < data.d.results.length; i++) {
	var projectName = data.d.results[i].Title;
	var projectURL = data.d.results[i].ProjectURL;

	//set matcheditem var to array of dasboardItems objects filtered by matching projectdesc to projectName
	var matcheditem = $.grep(dashboardItems, function(n){
		return n.projectdesc == projectName;
	});
	
	//check length of resulting matcheditem array from above.
	//if > 0, call getProjectRow using first item in matcheditem array.
	if(matcheditem.length > 0) {
		getProjectRow(projectName, projectURL, matcheditem[0].projectstatuslabel);
	}
	
}

Open in new window


Hope that helps.
0
 

Author Comment

by:Techsavy
ID: 40439109
Thank you ..I will give this a try...
0
 

Author Closing Comment

by:Techsavy
ID: 40446019
Thank you. Worked like a charm!
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question