I have the following list

enter image description here how can i retrive the value of koha column for first row and second row separate, datatype for koha column is number and how to assign value of koha into a variable var result how can i do that in JavaScript?


Screenshot seems your environment is SharePoint 2013. So you can accomplish it using REST API.

Getting the value of koha column for first row


Make a HTTP GET request in the above URL. Now assign the value into result inside success callback.

  • $select: which columns you wish to see in result.
  • $top: how many rows

If you need only the values of koha column, then ignore $top=1.


If you are using jQuery, then you can write your code like following

function getItems(url) {
        url: _spPageContextInfo.webAbsoluteUrl + url,
        type: "GET",
        headers: {
            "accept": "application/json;odata=verbose",
        success: function (data) {
            var result = data.d.result;
        error: function (error) {

Now call it like following

var url = "/_api/Web/Lists/GetByTitle('ListName')/Items?$select=koha&$top=1"

If you are interested to understand the whole thing, then have a look on my article.

CRUD Operation to List Using SharePoint 2013 Rest API

  • in you article i am referring to GET Items From List where this /_api/Web/Lists/GetByTitle('ListName')/Items?$select=koha&$top=1 goes I am new to SP development so thank you – Nderon Hyseni Dec 4 '15 at 9:27
  • you can call it using jQuery. In my article, there is example – Atish Dipongkor - MVP Dec 4 '15 at 9:29
  • Find an update or have a look on my whole article. @NderonHyseni – Atish Dipongkor - MVP Dec 4 '15 at 9:35
  • how can we contact I need something from you? i can pay you! – Nderon Hyseni Dec 4 '15 at 9:53
  • ok i added you to my skype at night we talk or at sunday – Nderon Hyseni Dec 4 '15 at 10:01

Once the listview has loaded all the info is in the ''ctx.ListData.row'' array so no need for REST or JSOM code

A quick and easy way is to hide that listview and do whatever you want with the data sharepoint loaded for you in the listview

Another option is to use CSR client side rendering, and get the value from ''ctx.CurrentItem.value''


If you want to get a single item, you need the ID then you can use JSOM

getListItem = function(siteURL, listNameSTR, itemID)
    var ctxOBJ = new SP.ClientContext(siteURL);
    var listOBJ = ctxOBJ.get_web().get_lists().getByTitle(listNameSTR);
    var itemOBJ = listOBJ.getItemById(itemID);
    return itemOBJ; 

My preferred way would be to use Client Side Rendering.

The code below will give you an array result that contains values of the koha field for all items in the current view.

var result = [];

SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", CSR_Setup);

function CSR_Setup() {
    var overridectx = {};
    overridectx.Templates = {};
    overridectx.Templates.Fields = {
        "koha": { "View": GetFieldVals }

function GetFieldVals(ctx) {
    var fieldVal = ctx.CurrentItem[ctx.CurrentFieldSchema.Name];
    return fieldVal;

Note the field name koha in the CSR_Setup function needs to be the internal name of the field.

Then iterate over the result array like so:

for (int i=0; i<result.length; i++) {
  • so now result has both values 30 and 25? – Nderon Hyseni Dec 4 '15 at 10:48
  • Yep result is an array with both values. Then iterate over the array in the normal fashion with a loop. I've updated my answer. – Submits Dec 4 '15 at 10:50

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.