2 Replies Latest reply on Jan 16, 2018 2:08 PM by ashleyg RSS
    ashleyg Apprentice

    Unordered DataTable entries when adding new rows

    Hi All,


    I am currently working on a geofencing project and have set up a DataTable to store temporary location vaues for users to freeform a geofence and create a region when they wish. I have a service which adds a DataTable entry every time a user double clicks the Google Maps widget where they would like to create a freeformed geofence. The primary key for this DataTable is currently setup to be an "ID" integer property of the DataTable which increments after every DataTable Entry.

    The service below is what I use to add a location to the DataTable everytime the user double clicks the Google Maps widget:


    var values = Things["GeofenceFreeformLocationsDataTable"].CreateValues();


    values.location = location; //LOCATION

    values.ID = me.ID;


    var params = {

      sourceType: undefined /* STRING */,

      values: values /* INFOTABLE*/,

      location: location /* LOCATION */,

      source: undefined /* STRING */,

      tags: undefined /* TAGS */



    // result: STRING

    var id = Things["GeofenceFreeformLocationsDataTable"].AddDataTableEntry(params);


    me.ID = me.ID + 1;


    However for some reason when adding DataTable entries they seem to be added to the DataTabe in an unordered way (see below). This is bad as when creating a region because the locations are out of order and therefore produce an obscure polygon when executing the CreateRegion() service I have.


    Unordered DataTable Entries.png


    Note: My mashup is rather full of scripts making development in the mashup editor slow with multiple services running at the same time, could this be a possible cause? Could the system settings possibly cause my issue? Also notice my timestamp appears to be midnight of the current day, is this a possible cause?


    Is it possible to add DataTable entries in order without having too manipulate the unordered DataTable in a service?


    Any advice would be greatly appreciated.


    Many Thanks