7 Replies Latest reply on Sep 19, 2017 11:48 AM by Marcos Vainer Loeff

    PI Web API: Query AF Table

    Doddabasappa

      Hi,

      I would like to know syntax to pass where condition parameters while making web api query to AF Table along with selected fields.

       

      https://<PIweb api machinename>/piwebapi/tables/ afTablewedid /data?selectedFields=Rows.Equipment Class;Rows.EquipmentTagName;Rows.Monitoring

       

       

      example:

      select equipment class, EquipmentTagname, Rows monitoring from aftable

      where Rows monitoring=1

        • Re: PI Web API: Query AF Table
          Roger Palmen

          Looking at the WebAPI documentation, it seems you can't get partial data results from your AF table. Only the full table.

          • Re: PI Web API: Query AF Table
            gregor

            Hello Doddabasappa,

             

            I believe Roger is right. I see as well no way to specify any where conditions when querying AF Table data.

            To my understanding, the reason of having AF Tables is to supply AF Attributes with values, either fixed or condition based. I really don't know if this makes any sense to you but can you please describe your use case so we might be able to suggest some way you could get the information you are looking for from an AF Attribute.

             

            Other than this, please feel encouraged to create an enhancement request at Uservoice - PI Developer Technologies -> PI Web API. You may want to post the link to your enhancement request here to allow other users to comment on and vote for it.

              • Re: PI Web API: Query AF Table
                Doddabasappa

                Hi Gregor,

                 

                We have requirement to display drop down list items from AF Table after applying some conditions instead of all rows.

                Such that users can make their choice of items from lists and choose time range. Accordingly we make PI web API query to fetch event frames data and populate response on web page.

                 

                If this option on AF table is not available then I think I have to write few more lines of code to achieve this.

                 

                Thanks,

                  • Re: PI Web API: Query AF Table
                    gregor

                    Hello Doddabasappa,

                     

                    Doddabasappa T wrote:

                     

                    Hi Gregor,

                     

                    We have requirement to display drop down list items from AF Table after applying some conditions instead of all rows.

                     

                    Sorry, but this was already clear from your initial question.

                     

                    When asking for your use case, I was hoping you would describe what assets you are dealing with and what information is coming from the table.

                    My guess is that your table has some KPI's related to different types of assets and that you need this information with your Event Frames. If this is the case, you should be able to define a parameterized query with an attribute for each asset, getting the required information from the table. Under the assumption that you create your event frames element related, you should have the all attribute information available for event frames too.

                     

                    If the above does not work for you, we are even more interested in your use case. Answers to questions like the following would be useful.

                     

                    - What assets are you dealing with?

                    - What information do you store in the AF table?

                    - How does that information refer to your event frames?

                    • Re: PI Web API: Query AF Table
                      Eugene Lee

                      Hi Doddabasappa,

                       

                      You can use jQuery filter function to filter it client side instead. Would this work for you?

                      http://api.jquery.com/filter/

                       

                  • Re: PI Web API: Query AF Table
                    eradwan

                    Hi All,

                     

                    I have a bit similar requirement where the AF table is dynamic - will be populated from an Inspection DB -  and its expected to to return a number of rows for each equipment. If - per the above - passing parameter is a problem; is it wise to create an AF table per equipment and have the equipment name hard coded in the table definition? My plan after that is to display the retrieved records in table like data grid within a custom symbol.

                     

                    Emad.

                      • Re: PI Web API: Query AF Table
                        Marcos Vainer Loeff

                        Hello Emad,

                         

                        I think it really depends on:

                        - Size of the AF table

                        - Resources available by your enterprise

                        - Number of equipments

                         

                        The easiest solution is to retrieve the full AF table and filter the rows on the client size. Nevertheless, if the table is too big if might take a long time to make the HTTP request.

                         

                        Having an AF table per equipment helps reduce the duration of the HTTP requests but it requires more effort to manage them.

                         

                        The last option is to create a custom ASP.NET Web API with PI AF SDK in order to filter the tables values on the server side. This option takes even more effort to maintain and manage but it solves the problem.

                         

                        Hopefully this feature will be implemented on the upcoming versions of PI Web API.

                         

                        Hope this helps!