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

x
?
Solved

SPFilterNode("z:\\row,row") -- Line of code being skipped

Posted on 2014-03-13
2
Medium Priority
?
2,669 Views
Last Modified: 2014-03-14
I have part of an overall AJAX display code that I have been asked to modify. I am trying to figure this out without help for the last 3 hours but now I am stuck.  Most of the code is working fine and no errors are getting triggered anywhere. However, when this filter component goes to search through the data nothing happens and none of the ows variables get populated.

Please keep in mind this is part of a lot of other code but I am starting with the section that is causing the issue.

Through debugging I determined the line of code that is not working as expected is:

$(xData.responseXML).SPFilterNode("z:\\row,row").each(function(index, value) {

Open in new window


Large function below--- I am wondering if it is something behind the scenes - perhaps a reference to the appropriate jquery js file but again no error is getting triggered.


function GetCensusRegionTargets (Company, TargetStart, TargetEnd) {
	//Used to get the target information for the individual census regions
	
	var ows_FieldItem, ows_SpeakerItem, ows_TargetStart, ows_TargetEnd;
	
	//Cleaning up the target start and end dates by removing trailing information
	TargetStart = TargetStart.substr(0 , TargetStart.indexOf("T"));
	TargetEnd = TargetEnd.substr(0 , TargetEnd.indexOf("T"));

	//Executing a web service call (using SPServices) to get all the census region target information
	$().SPServices({
		operation: "GetListItems",
		async: true,
		webURL: "/prd/hcctesting/risk/",
		listName: "Observation Targets",	
		completefunc: function (xData, Status) {
			//console.log("GetListItems operation: " + xData.responseText);		

			//Once the web service call is completed, then we iterate through the items to find a value that matches the current Company
			$(xData.responseXML).SPFilterNode("z:\\row,row").each(function(index, value) {
	      		//console.log(index + " : " + encodeURI($(value).attr("ows_Title")));
				
				//Cleaning the start and end dates from the web service call to remove trailing info
				ows_TargetStart = $(value).attr("ows_TargetStart");
				ows_TargetStart = ows_TargetStart.substr(0, ows_TargetStart.indexOf(" "));

				ows_TargetEnd = $(value).attr("ows_TargetEnd");
				ows_TargetEnd = ows_TargetEnd .substr(0, ows_TargetEnd .indexOf(" "));
					
				
				//ows_OMJPICIATarget = $(value).attr("ows_OMJPICIATarget");
				
				//Checking to see if the observation type is a field or speaker
				if ($(value).attr("ows_ObservationType") == 'Field Observation') {			

					//Cleaning the speaker/franchise name from the web service call to remove leading info
	      			ows_FieldItem= $(value).attr("ows_TargetCompany");
					ows_FieldItem= ows_FieldItem.substr(ows_FieldItem.indexOf("#") + 1, ows_FieldItem.length);
					
					console.log(ows_FieldItem);
				
	      			if ((Company == ows_FieldItem) && (TargetStart == ows_TargetStart) && (TargetEnd == ows_TargetEnd))  {	
	      				//console.log("Match Found (field): " + FranchiseSpeaker );
						
						//LEAVING to append target values
						AppendTargetValues(value)

						//Breaking the each loop
						return false;
	        		}

				} else if ($(value).attr("ows_ObservationType") == 'Speaker Observation') {
					//Cleaning the speaker/franchise name from the web service call to remove leading info
	      			ows_SpeakerItem = $(value).attr("ows_TargetSpkBureau");
					ows_SpeakerItem = ows_SpeakerItem .substr(ows_SpeakerItem .indexOf("#") + 1, ows_SpeakerItem .length);
					
					//console.log(ows_SpeakerFranItem);
	      			if ((Company == ows_SpeakerItem) && (TargetStart == ows_TargetStart) && (TargetEnd == ows_TargetEnd))  {	
	      				//console.log("Match Found (speaker): " + FranchiseSpeaker );
						
						//LEAVING to append target values
						AppendTargetValues(value)

						//Breaking the each loop
						return false;
	        		}

				}

	      	});

			//LEAVING to calculate the Gap values in the sub-details page
			CalculateSubDetailsGapValue ("ost-SubDetailsTable",true)
			
			//Setting the jQuery UI tool tips
			$("#SDViewAJAX").tooltip();
		}
	});

Open in new window

0
Comment
Question by:aehrenwo
[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 Comments
 
LVL 5

Accepted Solution

by:
Robin Hall earned 2000 total points
ID: 39929974
I use similar code in my sharepoint server to pull information from a SharePoint list and put it into a Visual Slider.  However I don't use SPServices (wasn't aware of it at the time I wrote the code)

I looked around a bit for SPServices functionality and came across this article which deals with the .SPFilternode portion:  SPServices Stories

In it, he uses the .SPFilterNode but his formatting is different than the line you use.  I'll past the relevant code bit below:

.SPFilterNode(“z:row”)

Maybe you can try to change your section after .SPFilterNode to look like the above.  You can read the article I included for more information.  Within the code that I use for my Slider, my z information looks like so:  .("z\\:row").

It might be worth trying both methods.
0
 

Author Closing Comment

by:aehrenwo
ID: 39929985
Thanks the first option worked.
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

722 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