ClearBlade Intelligent Assets

Advanced reports

Advanced reports allow users to create reports formatted to meet their specific needs. Optional schedules can be created for automatic delivery of the reports.

Advanced reports require development of a custom code-service. Use the following as a sample:

JavaScript
function sample(req,resp){


   var reportObj = {
       columns: [{
           columnType: "text",
           field: "YOUR_FIELD",
           title: "YOUR FIELD"
       }, {
           columnType: "text",
           field: "YOUR_OTHER_FIELD",
           title: "YOUR OTHER FIELD"
       }],
       data: []
   };


   function getAllAssets() {
       var assetsCollection = ClearBladeAsync.Collection('assets');
       var query = ClearBladeAsync.Query();
       query.equalTo('type', 'YOUR_ASSET_TYPE');
       return assetsCollection.fetch(query).then(function (results) {
           return results.DATA;
       });
   }


   getAllAssets().then(function(allAssetDetails) {
       for (var x = 0; x < allAssetDetails.length; x++) {
           var row = {};
           //fields ex: id, label, custom_data, location
           row.YOUR_FIELD =allAssetDetails[x].YOUR_FIELD
           row.YOUR_OTHER_FIELD = allAssetDetails[x].YOUR_OTHER_FIELD
           reportObj.data.push(row);
       }
       resp.success(reportObj);
   }).catch(function (reason) {
       console.error('failed: ', reason);
       resp.error(reason);
   });
  
}


See here for general information on adding reports. Select Advanced to create an Advanced report.

image-20251107-142853.png

On the INFO tab enter:

  • Label

  • Group (designates who will have access to the report)

  • Code Service

  • Type (used in Plugins)

On the SCHEDULES tab:

  • Click + to add a schedule.

    image-20251107-143320.png
  • Set up the schedule.

    image-20251107-143427.png

Click CREATE to create the report.


For further resources on creating code-services see here: