I work on a project that requires me to pull data from a SharePoint 2013 list and displays that data into html table. All data is being queried and displayed, however two lookup columns are displaying an "ID;#". How can I remove this from the front of the values, and just display the value ?
function get() {
var method = "GetListItems";
var webURL = $().SPServices.SPGetCurrentSite();
var list = "QA_DailyStatus";
var fieldsToRead = "<ViewFields>" + "<FieldRef Name='ProjectRelease' />" + "<FieldRef Name='StastusDate' />" + "<FieldRef Name='ProductionReleaseDate' />" + "<FieldRef Name='Overall_QA_Status' />" + "<FieldRef Name='Overall_QA_Percent_Complete' />" + "</ViewFields>";
var query = "<Query><Where><Eq><FieldRef Name='Active_DSR' /><Value Type=\"bit\">1</Value></Eq></Where></Query>";
$().SPServices
({
operation: method,
async: false,
webURL: webURL,
listName: list,
CAMLViewFields: "<ViewFields Properties='True' />",
CAMLQuery: query,
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function () {
var Release = $(this).attr("ows_ProjectRelease");
var StatusDate = $(this).attr("ows_StastusDate");
var ProductionDate = $(this).attr("ows_ProductionReleaseDate");
var OverallStatus = $(this).attr("ows_Overall_QA_Status");
var PercentComplete = $(this).attr("ows_Overall_QA_Percent_Complete");
$("#myDataTable").append("<tr align='middle'>" +
"<td align='left'>" + Release + "</td>" +
"<td align='left'>" + StatusDate + "</td>" +
"<td align='left'>" + ProductionDate + "</td>" +
"<td align='left'>" + OverallStatus + "</td>" +
"<td align='left'>" + PercentComplete + "</td>" + "</tr>");
});
}
});
};
You can use string manipulation. In the example below the substring starts at a specified character position and continues to the end of the string (removing the first n characters: in the given case - "ID:"):
$(this).attr("attribute name").substring(3);