call column list unsuccessfull
-
- Posts: 1
- Joined: Sat Apr 02, 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'));
}
Listen, I could replicate your situation on my setup, but for that I need to know the exact field types you're using. To make it easier on me, since you seem to be proficient enough in JS do this:
1. Insert 'debugger;' to the beggining of each of the three functions, e.g.
And save.
2. Then open the console (F12) in your browser, go onto the page
3. Your code execution will break at the 'debugger;' statement. From that point you can execute your code line by line to see where it's going wrong.
1. Insert 'debugger;' to the beggining of each of the three functions, e.g.
Code: Select all
function getUserDetails() {
debugger;
...//the rest of your code
}
2. Then open the console (F12) in your browser, go onto the page
3. Your code execution will break at the 'debugger;' statement. From that point you can execute your code line by line to see where it's going wrong.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 23 guests