I would like to retrieve data from a list that has 2 columns but 4 fields.

Ex. I need the calculation from monthly & yearly cost from group 1 and calculations for monthly cost & yearly cost based on group 2.

I think some JavaScript should do the trick just don’t know where to start.

Please help.

1 Answer 1


This is easy done with JavaScript:

Retrieve Function will be something like this:

var siteUrl = '/sites/MySiteCollection';

function retrieveListItems() {

    var clientContext = new SP.ClientContext(siteUrl);
    var oList = clientContext.get_web().get_lists().getByTitle('ListName');

    var camlQuery = new SP.CamlQuery();
    this.collListItem = oList.getItems(camlQuery);


    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));        


function onQuerySucceeded(sender, args) {

    var listItemInfo = '';

    var listItemEnumerator = collListItem.getEnumerator();

    while (listItemEnumerator.moveNext()) {
        var oListItem = listItemEnumerator.get_current();
        var group1Calculation=0;
        var group2Calculation=0;
            group1Calculation += parseInt(oListItem.get_item('monthly')) + parseint(oListItem.get_item('monthly'));

            group2Calculation += parseInt(oListItem.get_item('monthly')) + parseint(oListItem.get_item('monthly'));



function onQueryFailed(sender, args) {

    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.