call column list unsuccessfull
Posted: 03 Apr 2016
Need your kind assistant to help me for camlquery. I intended to insert data inside form respectively. but currently it seems when i do query i doesn't fetch any data as no error pop out.
Here is my code, thanks
P/S:- for LoggedInUser variable I have successfully get the information
function getUserDetails() {
context1 = new SP.ClientContext.get_current();
oList = context1.get_web().get_lists().getByTitle('Employee Leave Record List');
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml(
'<View><Query><Where><Eq><FieldRef Name=\'EmpName\'/>' +'<Value Type=\'Text\'/>'+ LoggedInUser +'</Value></Eq></Where></Query></View>'
);
collListItem = oList.getItems(camlQuery);
context1.load(collListItem);
context1.executeQueryAsync(onQuerySucceeded,onQueryFailed);
}
function onQueryFailed(sender , args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
function onQuerySucceeded(sender , args) {
var listItemEnumerator = collListItem.getEnumerator();
while (listItemEnumerator.moveNext()) {
var oListItem = listItemEnumerator.get_current();
fd.field('Employee_x0020_Number').value(oListItem.get_item('Employee_x0020_Number'));
fd.field('Position').value(oListItem.get_item('Position'));
fd.field('Department').value(oListItem.get_item('Department'));
console.debug(fd.field('Employee_x0020_Number'),fd.field('Position'),fd.field('Department'));
}
Here is my code, thanks
P/S:- for LoggedInUser variable I have successfully get the information
function getUserDetails() {
context1 = new SP.ClientContext.get_current();
oList = context1.get_web().get_lists().getByTitle('Employee Leave Record List');
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml(
'<View><Query><Where><Eq><FieldRef Name=\'EmpName\'/>' +'<Value Type=\'Text\'/>'+ LoggedInUser +'</Value></Eq></Where></Query></View>'
);
collListItem = oList.getItems(camlQuery);
context1.load(collListItem);
context1.executeQueryAsync(onQuerySucceeded,onQueryFailed);
}
function onQueryFailed(sender , args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
function onQuerySucceeded(sender , args) {
var listItemEnumerator = collListItem.getEnumerator();
while (listItemEnumerator.moveNext()) {
var oListItem = listItemEnumerator.get_current();
fd.field('Employee_x0020_Number').value(oListItem.get_item('Employee_x0020_Number'));
fd.field('Position').value(oListItem.get_item('Position'));
fd.field('Department').value(oListItem.get_item('Department'));
console.debug(fd.field('Employee_x0020_Number'),fd.field('Position'),fd.field('Department'));
}