Quantcast
Channel: jQuery Library for SharePoint Web Services
Viewing all articles
Browse latest Browse all 6517

New Post: GetListItems Returns "undefined" for a field

$
0
0

Hi,

I am trying to retrieve data from a list in sharepoint. With the fields 

RISK_SLNO,
RISK_TYPE_HEADER
RISK_TYPE
RISK_HAVE_HEADER
RISK_OWNER
RISK_RAGCURRENT
RISK_RAGPROJECTED
RISK_STATUS_CURRENT

And in the page I have written code to get data from this list. It is working but for 2 fields its returningundefined in the table i am creating with the data. All fields are showing not these two fields. 

RISK_RAGCURRENT
RISK_RAGPROJECTED

I have cross checked the field names in the code many times, tried chenging the name also. But nothing is working. 

Below is my code 
var fieldsToRead =  "<ViewFields>" +
                               "<FieldRef Name='RISK_SLNO'/>" +
                                "<FieldRef Name='RISK_TYPE_HEADER'/>" +
                                "<FieldRef Name='RISK_TYPE'/>" +
                                "<FieldRef Name='RISK_HAVE_HEADER'/>" +
                                "<FieldRef Name='RISK_OWNER'/>" +
  "<FieldRef Name='RISK_RAGCURRENT'/>" +
    "<FieldRef Name='RISK_RAGPROJECTED'/>" +
                             "</ViewFields>"; 

var query = "<Query>" +
                             "<Where>" +
                                     "<Neq>" +
                 "<FieldRef Name='RISK_TYPE_HEADER'/><Value Type='Text'>~</Value>" +
                                             "</Neq>" +
                                                     "</Where>" +
                                                     "<OrderBy>" +
                                             "<FieldRef Name='ID'/>" +
                                     "</OrderBy>" +
                             "</Query>"; 

                $().SPServices({                                    
operation: "GetListItems",
             async: false,
             listName: "riskmap_master",
             CAMLViewFields: fieldsToRead,
             CAMLQuery: query,
             completefunc: function (xData, Status) {             $(xData.responseXML).SPFilterNode("z:row").each(function() {

     var vRISK_ID = ($(this).attr("ows_RISK_SLNO"));
             var vRISK_TYPE_HEADER = ($(this).attr("ows_RISK_TYPE_HEADER"));
             var vRISK_TYPE = ($(this).attr("ows_RISK_TYPE"));
             var vRISK_HAVE_HEADER = ($(this).attr("ows_RISK_HAVE_HEADER"));
             var vRISK_OWNER = ($(this).attr("ows_RISK_OWNER"));
             var vRISK_RAGCURRENT =($(this).attr("ows_RISK_RAGCURRENT"));
             var vRISK_RAGPROJECTED=($(this).attr("ows_RISK_RAGPROJECTED"));
             var vRISK_COV = "LINKFORTEST";
             var vRISK_RED = "LINKFORTEST";

 //call a function to add the data from the row to a table on the screen                         AddRowToTable(vRISK_ID,vRISK_TYPE_HEADER,vRISK_TYPE,vRISK_HAVE_HEADER,vRISK_OWNER,vRISK_RAGCURRENT,vRISK_RAGPROJECTED,vRISK_COV,vRISK_RED);                                }); } }); } 

 

Now the 2 lines 
             var vRISK_RAGCURRENT =($(this).attr("ows_RISK_RAGCURRENT"));
             var vRISK_RAGPROJECTED=($(this).attr("ows_RISK_RAGPROJECTED"));
returning undefined in the html table. Where as I tried to assign fixed value to the above like

             var vRISK_RAGCURRENT ="TEST_CURRENT";
             var vRISK_RAGPROJECTED=TEST_PROJECTED;
And this worked, It showed in the table.

Kindly guide me, where I am doing wrong. 

This happened before also. I imported a excel spreadsheet to create a new list. And SPServices as not able to find the column names and returned undefined error. When I created the fields manually, it worked. Please tell me what I am missing here.


Viewing all articles
Browse latest Browse all 6517

Trending Articles