Main Function to call for CallBack
function checkDuplicates(projectCode, callback) {
var url = appWebUrl + "/_api/SP.AppContextSite(@target)/web/lists/getbytitle('" + projectListName + "')/items?$select=ProjectCode&$filter=ProjectCode eq '" + projectCode + "'&@target='" + hostWebUrl + "'";
var IsDuplicate = false;
var executor = new SP.RequestExecutor(appWebUrl);
executor.executeAsync({
url: url,
method: "GET",
headers:
{
"accept": "application/json;odata=verbose"
}, contentType: 'application/json',
success: function (data)
{
var jsonObject = JSON.parse(data.body);
var object = jsonObject.d.results
if (object.length > 0)
{
IsDuplicate = true;
}
callback(IsDuplicate);
},
error: function (errorData) { console.log(errorData.message); }
});
}
Way of calling the CallBack function
checkDuplicates(enteredProjectCode, function (data)
No comments:
Post a Comment