Skip to main content


SUBLIST sum based on sublist field


1 comment

  • ArdeviaForum

    Original Post by Andrii Katsiubka (Imported from Ardevia Forum)

    Hi Rick,


    Yes, its possible. But now only with custom script. Follow the next steps to achieve your behavior:


    1. Select field in which you want to show calculation result


    2. Open Behavior tab and click on expression builder button for calculated expression


    3. Select "Function code" expression type from the dropdown on the top of expession builder dialog


    4. Insert code bellow:

    var t = [[@SubLists.YourSublist.CalculatedField]];
    var a = [[@SubLists.YourSublist.ExpenseTypeField]];
    var webpartId = "YourSublistWebPartId";
    var webpartSelector = "[ard-webpart-id=" + webpartId + "]";
    var gridController = jQuery(webpartSelector).data('Controller');
    var grid = gridController.InstanseData;
    var recordsIds = grid.GetAllRecordIds();
    var total = 0;
    for (var i = 0; i < recordsIds.length; i++){
        var id =  recordsIds[i];
        var expType = grid.GetRowValue(id, 'ExpenseTypeField');
        var price = grid.GetRowValue(id, 'CalculatedField');
        if (expType == "Food"){
          var parsed = parseFloat(price);
          total += isNaN(parsed) ? 0 : parsed;
    return total;

    5. Replace placeholders from first two lines with own fields from your sublist (Also you can find them under Context Objects -> SubLists )


    6. Replace YourSublistWebPartId in line 3 with your sublist webpart id.
    To find this Id open developer tools in your browser (press F12 key). Select sublist and find a ard-webpart-id attribute on the parent element .



    7. Replace 'ExpenseTypeField' and 'CalculatedField' in lines 11 and 12 with corresponding internal names of fields from your sublist


Please sign in to leave a comment.