Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
I have some strange behavior that I can't tell what I may be doing wrong.
I have a Stream with a service that deletes stream entries that match a field query for the same value.
this service takes an input string var named SR_Num.
CODE:
STREAM: DELETE ENTRY CODE
var srTable = me.FindSr();
var IDs = []
if (srTable.length > 0){
for(var i=0; i< srTable.length;i++){
var thisID = srTable.getRow(i).id;
IDs.push(thisID);
me.DeleteStreamEntry({streamEntryId:thisID});
}
}
result = "Deleted " + srTable.length + " entries. " + IDs.join(", ");
From My Thing I have a timer subscription that updates the stream from an info table but first calls this Delete Service
CODE:
THING: UPDATE STREAM CODE
...
for(var i=0;i<SRTable.length;i++){
var row = SRTable.getRow(i);
logger.warn("SR Number: " + row.SR);
//Delete Existing SRStream entries for SR
Things["SRStream"].DeleteSrFromStream({SR_Num:
row.SR
});...
The Issue:
When I send a STRING "63918566" (Verified with a logger.warn call ) to the service DeleteSRFromStream.
DeleteSRFromStream gets the STRING "6.3921924E7" appears that the string is converted to a number for some reason.
work around:
I found a workaround by adding a char at the start of the string to prevent the conversion to a number that appears to be happening.
Example: Send "_63918566" Get "_63918566"
Is there something I'm doing wrong or is there a bug some place?
The JavaScript tried to convert string to number. Can you log logger.warn(typeof row.SR) too ?
You would need to reconvert to string with .toString()