5 Replies Latest reply on Aug 4, 2017 6:39 AM by khayes RSS
    khayes Explorer

    size of a returned infotable

    Hi,

     

    I would like to set the visibility of some of my widgets according to the number of rows in an infotable that is returned from a service. So, for example, if the resulting infotable had 0 rows I might like to hide a button.

     

    Is it possible to write a generic service that would take the result (infotable) of one service as the input parameter of a second service, without needing to know the datashape associated with the infotable of the first service and return the number of rows. Or is there a better way to determine the number of rows in a result?

      • Re: size of a returned infotable
        supandey Collaborator

        Kieron, are you just looking for a function that can return the Row count? or you do you also need to perform some computation before the infotable returned from 1st service could be passed on to the 2nd service? I suppose if it's just with the row count you could use the Infotable function called .getRowCount()

          • Re: size of a returned infotable
            khayes Explorer

            Hi, thanks for the reply.

            I don't have any additional computation to do, and as you say, I intended to use .getRowCount() in my second service, but wasn't sure if I could pass an infotable to the second service without knowing its datashape. So I might have 2 services that return infotables based on 2 different shapes

            1. result1 = MyGetImplementingThings() ;

            2. result2 = MyQueryAlerts() ;


            each of the above will return an infotable, but they will be based on different datashapes. I'd like to pass the results of both into a generic service that would return me the number of rows. e.g.

            var count1 = GetNumRows(result1);

            car count2 = GetNumRows(result2);


            Is that possible?

            Thanks,

            K

              • Re: size of a returned infotable
                supandey Collaborator

                Sorry I have not tested it, so can't say for sure but as long as you are not attempting to combine two Infotables with different Datashapes i think it should work. Besides how it looks like here you only need the row counts so I suppose it's only getting total row counts from both infotables and then adding them up so for this purpose alone I don't see the need to know the datashapes.

                 

                However, this'd be a different story if you actually plan to use something like Union() because that'll require both Infotables to have same datashapes

                  • Re: size of a returned infotable
                    khayes Explorer

                    Hi Sushant, thanks for getting back to me. I don't intend to use them together, or add the results. I just wanted a generic service that I could use with any mash up. I have a couple of 'utility' things which I use for library type services, so I would probably add it as a service to one of those.

                     

                    I'll give it a go tonight to see how I get on.

                    Thanks,

                    K

              • Re: size of a returned infotable
                khayes Explorer

                Finally got around to testing this and it is possible to write a generic service to return the number of rows in a returned infotable, regardless of the datashape of the infotable.

                 

                It is as simple as not selecting any datashape for the input. The service can then contain a simple 1 line of code...

                result = inputTable.rows.length ;

                seems to work okay.