Value from Payload is empty

#1

I am new to red node and trying to set up a flow to insert messages in a MS SQL database.

I am having difficulty passing the values from the payload to the query. I can successfully insert into my table as long as a don't have any variables and the values are hard coded. Unfortunately when I pass a value to the query from the payload, my string is empty.

I am using a template node set to plain text to prepare the query for the sql node.

Inject Node:
Payload is set to JSON
{
"service": "myServiceName"
}

Template Node:
Insert into ActivityLog (ServiceName, MessageType, MessageText)
Values('{{msg.payload.service}}', 'sdfsd', 'sdfs');

Result in Debugging (empty string where my value should be):
Insert into ActivityLog (ServiceName, MessageType, MessageText) Values('', 'sdfsd', 'sdfs');

Thanks is advance for any guidance you can offer!

0 Likes

#2

If you look at a "new" template node after you have dragged it onto the canvas you will see

This is the payload: {{payload}} !

So the chances are your Values('{{msg.payload.service}}', 'sdfsd', 'sdfs');
should be Values('{{payload.service}}', 'sdfsd', 'sdfs');

1 Like

#3

Thank you @ukmoose! That was it. I replaced msg.payload.service with payload.service. Thanks for the quick response!

0 Likes