0

This is my Function :

function RetrieveNewChange(ChangeID) {
var getItemsUrl = "/_api/Web/Lists/GetByTitle('" + ChangeList + "')/items?$select=ID,Title,Employee/Id,Employee/Title,Employee/FullName&$expand=Employee&$filter=(ID eq " + ChangeID + ")";
var promise = $.ajax({
    url: _spPageContextInfo.webAbsoluteUrl + getItemsUrl,
    type: "GET",
    headers: {
        "accept": "application/json;odata=verbose",
    },
    success: function (data) {
        console.log(data.d.results);


        if (data.d.results.length > 0) {
            var ArrayRetrieved = data.d.results[0];
            console.log(ArrayRetrieved);

            $('#lookup option[value="' + ArrayRetrieved.Employee.FullName + '"]').prop('selected', true)
            $("#lookup").trigger("chosen:updated");

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

But it don't work! I dont get the "ArrayRetrieved.Employee.FullName" value in the dropdown list! Please help.

1 Answer 1

0

Suppose you're setting lookup field selected value, use developer tool to check the dropdown value property(provide more details if not help).

enter image description here

//MyLookup is lookup field name, 7 is lookup item id.
$('select[title="MyLookup"]').val(7);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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