Rally Software

Expand all | Collapse all

How to hydrate Project in Lookback API

Jump to Best Answer
  • 1.  How to hydrate Project in Lookback API

    Posted 10-10-2017 12:50 PM

    I've been working for some time to tweak the Time Tracking by Actuals report - we don't use actual time tracking and aren't ready to. The original report is located here: GitHub - RallyTechServices/timetracking-by-actuals-change My last hurdle is that I need to see the Project at the task level. I've gotten it to show the Project's object ID, but I'd like it to show the Project Name. In the Lookback API, you can use the hydrate function on Project, but I am obviously not using the right syntax.  When I use  "hydrate": ["Project.Name"], I still only get the Object ID.  Any ideas?



  • 2.  Re: How to hydrate Project in Lookback API
    Best Answer

    Posted 10-10-2017 05:28 PM

    Hi MartiAndrews1358393,

     

    You can use the fields parameter in LBAPI to determine which fields are included in the results. Here is a definition of what Hydrate does also. You would probably hydrate Project and also include it in the fields.

    "fields": [ "Project", "FormattedID" ]

    "hydrate":  [ "Project" ]

     

    Let me know if that helps.

    -Sean Davis



  • 3.  Re: How to hydrate Project in Lookback API

    Posted 02-08-2018 10:31 AM

    Was going through some old stuff and realized I never posted the final code that got me what I needed.  Thanks davse04 for the tip on hydrating.  Within the original github report listed, here's where I added the hydrate for Project at the task level (in red, near the bottom):

      _findCurrentTaskValues: function(rows) {

            // snapshots from lookback have the value of fields at the time the

            // snap was taken

            this.logger.log('_findCurrentTaskValues',rows.length);

            var deferred = Ext.create('Deft.Deferred');

            this.setLoading('Fetching current task data...');

     

            var me = this;

                 

            var project_field = this.getSetting('typeField');

       

            var rows_by_oid = {};

            Ext.Array.each(rows, function(row) {

                rows_by_oid[row.ObjectID] = row;

            });

           

            var task_oids = Ext.Array.pluck(rows,'ObjectID');

           

            this.logger.log("# of tasks to fetch:", task_oids.length);

           

            var filter_array = task_oids;

           

            var chunk_size = 300;

            if ( !this.isExternal() ) {

                chunk_size = 1000;

            }

            var array_for_filters = [];

            while (filter_array.length > 0) {

                array_for_filters.push(filter_array.splice(0, chunk_size));

            }

           

               

            var promises = [];

            Ext.Array.each(array_for_filters,function(filters) {

                //var filters: Rally.data.wsapi.Filter.or(filters),

                var filters = [

                    {property:'_TypeHierarchy', value:'Task'},

                    {property:'ObjectID',operator:'in',value:filters},

                    {property: '__At',value: 'current'}

                ];

               

                promises.push( function() {

                    var config = {

                        filters: filters,

                        fetch  : ['Name',project_field,'WorkProduct','Project'],

                        /* I added Project here and hydrated it */

                        hydrate: ['Project'],

                        useHttpPost: true

                    };

                    return me._loadSnapshots(config);

                });



  • 4.  Re: How to hydrate Project in Lookback API

    Broadcom Employee
    Posted 02-08-2018 01:58 PM

    Super helpful for others, I'm sure! Thanks for updating!