How to add the field 'serie' in the Script, so that the data in the table appears on the same line?

Good Morning,

I’m sending some data received from my device to a pivot table, but I didn’t understand how to add the ‘serie’ field to my code. My data are on separate lines, I believe it is for this reason.

Hello @ghasantos, you can send the series as a json field when you send the data. More information https://docs.tago.io/en/articles/5-other-concepts

for example:

{
    "variable": "myVariable",
    "value": 10,
    "serie": "mySerie"
}

if that doesn’t help, put your code here :slight_smile:

payload.push({“variable”: “timestamptab”, “value”: dataresult},

           {"variable": "ppctab", "value": PPCstatus},

           {"variable": "gpstab", "value": gpsstatus},

           {"variable": "batterytab", "value": batstatus},

           {"variable": "speedtab", "value": speedtab},

           {"variable": "lattab", "value": latresult },

           {"variable": "longtab", "value": longresult},

           {"variable": "voltagetab", "value": voltagestr},

           {"variable": "odometertab", "value": odomconvert}

           );

you can do like this:

const mySerie = Date.now();
// creates a unique identifier for each series, in this case it takes the current time
payload.push({"variable": "timestamptab", "value": dataresult, "serie": mySerie},
           {"variable": "ppctab", "value": PPCstatus, "serie": mySerie},
           {"variable": "gpstab", "value": gpsstatus, "serie": mySerie},
           {"variable": "batterytab", "value": batstatus, "serie": mySerie},
           {"variable": "speedtab", "value": speedtab, "serie": mySerie},
           {"variable": "lattab", "value": latresult, "serie": mySerie},
           {"variable": "longtab", "value": longresult, "serie": mySerie},
           {"variable": "voltagetab", "value": voltagestr, "serie": mySerie},
           {"variable": "odometertab", "value": odomconvert, "serie": mySerie}
);

Thanks a lot for the help!
It worked here! :smiley:

1 Like