0
 var clientContext = SP.ClientContext.get_current();
 var lists = clientContext.get_web().get_lists();
 var oList = clientContext.get_web().get_lists().getByTitle(listName);
 var collListItem;
var camlQuery = new SP.CamlQuery();
    var viewXML = "<View Scope='RecursiveAll'><ViewFields>" +
"<FieldRef Name='FullName' />" +
"<FieldRef Name='JobTitle' />" +
"<FieldRef Name='CompanyDepartment' />"+
"</ViewFields></View>";
collListItem = oList.getItems(camlQuery);
clientContext.load(oList);
clientContext.load(collListItem); 

 clientContext.executeQueryAsync(
    function () {
        // We have the elements
        var listItemEnumerator = collListItem.getEnumerator();
         // It's easy to iterate and get the column values of an item
        while (listItemEnumerator.moveNext()) {
            var cItem = listItemEnumerator.get_current();

            var Obj = {
            Name:cItem.get_item('FullName'),
            JobTitle:cItem.get_item('JobTitle'),
            Photo:cItem.get_item('JoinerPhoto'),
            company:cItem.get_item('CompanyDepartment')

            };
            console.log(Obj );

        }


    },
    function (sender, args) {
        console.log('Error getting list items: ' + args.get_message());
    }
);

in My Code its obvious im retrieving some values from custom list with custom columns i created a column for the list called "JobTitle" and when i tried to retrieved in the while loop cItem.get_item('JobTitle') it threw an Error that field not initialized so i consoled out the cItem and i found that my firld name is "JobTitle1" "1" added at the end i dunno why and i wanna know how to know the real names of the fields thanks

  • I guess by now you understand the difference between display name and internal name. Just want to get your attention to query. You are creating a view but not setting the view in the camlquery object. As it is now, your code is not limiting the results to those fields only. – Nadeem Yousuf Jan 30 '15 at 16:28
  • so what if i want it to limit'em ? – Ahmed Aborady Jan 30 '15 at 21:40
  • @NadeemYousuf can you please send some resourse for simple explaining for this CamlQuery ? – Ahmed Aborady Jan 30 '15 at 23:17
1

If there was already a JobTitle column, and another was created, it would append a 1 to the end of it. The easiest way to check the internal column names is to go into the list/libary settings and click on the column. This will open the properties of the column, and the URL in the address bar will show the internal column name for use in CAML/Javascript.

Personally, I do this often, because I want consise column names. When I create them, I'd create it as JobType to set the internal name then edit the column to give a display name like Job Type. Display name does not always equal static name and using this trick, or things like the BIWUG CAML Designer help.

0

Those are field's internal names. You can find it by

  1. Open List Settings
  2. Then Hover mouse over the field (its a hyperlink)
  3. Look for a querystring with name Field

Another option is to use SharePoint Manager. It is a windows form application which gives you much more details.

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.