3 Replies Latest reply on May 24, 2017 3:30 AM by qngo Branched from an earlier discussion. RSS
    rvuta Explorer

    Is there any option to give to alias name to sql result columns like Target,Actual?

    Hi Sushant

     

    Now I have  to add sql service result to a data table as columns names are coming dynamically.

     

    DataTable have fields like "Product Name","Target","Actual".

    SQL service result is coming with column names as Target_A,Target_B..etc  on every iteration .

     

    How to map this result with data table object properties?

     

    Is there any option to give to alias name to sql result columns like Target,Actual?

     

    Regards,

    Raji.

     

    Message was edited by: Sushant Pandey branched from https://community.thingworx.com/message/58830#58830

      • Re: Is there any option to give to alias name to sql result columns like Target,Actual?
        qngo Creator

        Hi, with the SQL query, you can change the column names with "... Target_A AS Product_Name ..." right ? Or you can change the column name after retrieveing the data with RenameField

         

        var params = {

          t: data/* INFOTABLE */,

          from: "Target_A" /* STRING */,

          to: "Product Name" /* STRING */

        };

         

        // result: INFOTABLE

        var result = Resources["InfoTableFunctions"].RenameField(params);

        • Re: Is there any option to give to alias name to sql result columns like Target,Actual?
          qngo Creator

          Hi,

           

          1. Without knowing your whole usecase, I suggest using Localization Table and provide in advance a "translation" of all possible property names. Then retrieve its "translation" with service, for example:

           

          Resources["RuntimeLocalizationFunctions"].GetEffectiveToken({token: undefined /* STRING */})

          or

          Resources["RuntimeLocalizationFunctions"].GetEffectiveTokenForLanguage({language: undefined /* STRING */, token: undefined /* STRING */})

           

          2. In service zone, you can check it in two ways:

          i. Tab Snippets, type RenameField

          ii. Tab Entities, type InfoTableFunctions, then RenameField