2 Replies Latest reply on Jul 25, 2017 2:03 AM by slee-10-11 RSS
    slee-10-11 Newbie

    How create sequence from Data Tables?

    I starting to study thingworx

    I want create increase sequence to number in Thingworx Data Tables

    I made Data Tables after made Data Shapes and Fields

    I made Field of Five in the Fields so want to input sequence values into the Num Field

    How create sequence from Data Tables?

    I want simple source code if made from services or let me know if you have other way

      • Re: How create sequence from Data Tables?
        anna Creator

        Hi SANG HYUN LEE,

        Just share with you what I did to create sequence ID for data table.

        1. create a new Property named "ID" with NUMBER basetype under my Data Table

        2. In the Service where I add a new DataTable Entry

         

        var values = me.CreateValues();
        values.sourceType = undefined; //STRING
        values.location = undefined; //LOCATION
        values.source = undefined; //STRING
        values.key = me.ID; //STRING [Primary Key]
        values.timestamp = undefined; //DATETIME
        values.tags = undefined; //TAGS
        var params = {
         sourceType: undefined /* STRING */,
         values: values /* INFOTABLE*/,
         location: undefined /* LOCATION */,
         source: undefined /* STRING */,
         tags: undefined /* TAGS */
        };
        me.ID=values.key+1;
        // result: STRING
        var result = me.AddDataTableEntry(params);
        

         

         

        Hope this helps,

         

        Br,

        Anna