1

My Code is below..

function RetrieveProspect(ProspectID) { var getItemsUrl = "/_api/Web/Lists/GetByTitle('" + ListNameProspect + "')/items?$select=ID,Title,Domicile&$filter=(ID eq " + ProspectID + ")";

var promise = $.ajax({
    url: _spPageContextInfo.webAbsoluteUrl + getItemsUrl,
    type: "GET",
    headers: {
        "accept": "application/json;odata=verbose",success: function (data) {
        ArrayRetrieved = data.d.results;
        if (ArrayRetrieved.length > 0) {
            console.log(ArrayRetrieved);
            //LICENSES
            for (var i = 0; i < ArrayRetrieved.length; i++) {$("#Domicile").append(ArrayRetrieved[i].Domicile.Label);   }
        }
    },
    error: function (error) {
        console.log("Error on Retrieve Service");
        console.log(JSON.stringify(error));
    }
});

}

the debug :enter image description here

The result : 487

I would like to display the value :(

1

The solution i Found :

var viewXml = {
    ViewXml: "<View>" +
        "<Query>" +
        "<Where><Eq>" +
        "<FieldRef Name='ID' />" +
        "<Value Type='Number'>" + ProspectID + "</Value>" +
        "</Eq></Where>" +
        "</Query>" +
        "</View>"
}
var call = $.ajax({
    url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/getByTitle('" + ListNameProspect + "')/GetItems(query=@v1)?" +
        "@v1=" + JSON.stringify(viewXml),
    type: "POST",
    dataType: "json",
    headers: {
        Accept: "application/json;odata=verbose",
        "X-RequestDigest": $("#__REQUESTDIGEST").val()
    },

    success: function (data) {
        ArrayRetrieved = data.d.results;
        if (ArrayRetrieved.length > 0) {
            console.log(ArrayRetrieved);
            //LICENSES
            for (var i = 0; i < ArrayRetrieved.length; i++) { $("#Domicile").append(ArrayRetrieved[i].Domicile != null ? ArrayRetrieved[i].Domicile.Label : "");}

error: function (error) { console.log("Error on Retrieve Service"); console.log(JSON.stringify(error)); }, });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.