How to calulate length of

How to calculate length of .I want to differentiate between fob id and tag is which are of different sizes .please suggest?

Can you post an example of what you mean?

Maybe look at JavaScript .length

if(length of
do something...
if(length of
do something.....

Yes sir i tried this but no output whats wrong in this please answer

Hi @shipra

first we need to understand exactly what type of value you have in If you pass it to a Debug node, configured to display, that will show us what you have got.

If it is a String type of value, then you can use the length function on the String object -

So in this instance, you would get the length of with

If is not a String, but is actually some other type, then it depends on what that type is and what you want from it.

Sir i have tried this ,please suggest whats wrong in this is a string

var words='${}';
var i= words.length;
let newMsg1 = {};

newMsg1.topic = `INSERT INTO  NCS_DATABASE3 (Date_and_Time_India,Date_and_Time_UK ,Event_Type ,Event_Description ,Person_ID,Person_Name_Description ,Fob_Tag_ID ,Trade_ID,Door_ID ,Door_Description ,Status)
VALUES ((strftime('%Y-%m-%d %H:%M:%S','now','localtime')),(strftime('%Y-%m-%d %H:%M:%S','now','localtime','-4 hour','-30 minutes')),' ',' ',' ','Shipra Nigam',' ','${}',' ',' ','DR1 ON')`;
return newMsg1;

    let newMsg2 = {};

newMsg2.topic = `INSERT INTO  NCS_DATABASE3 (Date_and_Time_India,Date_and_Time_UK ,Event_Type ,Event_Description ,Person_ID,Person_Name_Description ,Fob_Tag_ID ,Trade_ID,Door_ID ,Door_Description ,Status)
VALUES ((strftime('%Y-%m-%d %H:%M:%S','now','localtime')),(strftime('%Y-%m-%d %H:%M:%S','now','localtime','-4 hour','-30 minutes')),' ',' ',' ','Shipra Nigam','${}',' ',' ',' ','DR1 ON')`;
return newMsg2;

Without knowing anything about what you want the code to do, I can only look for JavaScript mistakes.

The first line should be:

var words =;

error coming
check this

SELECT Fob_Tag_ID FROM NCS_DATABASE3 WHERE Fob_Tag_ID='04222436' : msg : Object
topic: "SELECT Fob_Tag_ID FROM NCS_DATABASE3 WHERE Fob_Tag_ID='04222436'"
_msgid: "ca43b588.7a0808"
payload: "CR_SUCCESS"
9/10/2020, 6:01:53 PMnode: a4cb6fc0.fed9function : (error)
"TypeError: words.length is not a function"

If words.length is not a function (which is what the error tells you), then words is not a String type of object - so therefore is not a String.

So I go back to my original reply - you need to confirm what type of value is. Pass it to a Debug node (configured to show and then show us what it reports when you pass a message to it.

Sir thank you so much now its working.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.