Well, don't do that. No one said to do that.
You want the switch node exactly as @zenofmud provided.
Well, don't do that. No one said to do that.
You want the switch node exactly as @zenofmud provided.
ok sorry.ya done ,so thats a switch ok
So what do you think you need to do with the Switch node?
You haven't connected it to anything there so it won't do much like that.
SEE LIKE THIS
There's no question there, so I assume you know what to do next?
I assume you've now tested it to see what message you get from each of its outputs?
Sorry, but I'm not sure what you want me to look at in that screenshot
Have you tested it? Is it working?
What do you want me to check? I know nothing about your application, I don't know what that screenshot is showing me.
It is a simple question - do you get a message from the Switch_debug
node when you enter a valid ID?
when i am entering valid id it is only showing the id,but when i am entering invalid id it is showing me empty
If you look at the Switch node's configuration, you can see it has a rule to check if msg.payload
is empty - and that will cause a message to be sent on the first output.
It's second rule is to check if it is not empty - and that will cause a message to be sent on the second output.
You have wired up the first output of the Switch node, so you will only get a message there if the ID doesn't match anything in the database.
If you want to handle messages that do match something in the database, use the second output of the Switch node.
You have named both debug nodes Switch_debug
- so from a static screenshot it's impossible to tell which message came from which node.
But you don't need me to tell you if its working - you should be able to see for yourself what happens when you inject a valid or invalid message.
YES SIR ,I want a string to be display there not empty(i want a CR_FAIL) string in case of invalid and (i want CR_SUCCESS) in case of valid.
You can use the Change node to set the payload of the message to whatever value you want.
Now the Switch node has done its job of separating out the invalid and valid messages, you can add one Change node wired to the top output to set the payload to CR_FAIL
and one Change node wired to the bottom output to set the payload to CR_SUCCESS
.
As before, add your Debug nodes after the Change nodes so you can check what it is doing.
Ya now its working
At this point, given what you've learnt so far, can you make a guess as how you might do that?
Hint - what node might you use to publish a message to an MQTT topic?
yes definitely , but sir one issue whenever i am passing E1234562 which is is my database it is showing CR_FAIL why
Do you understand how the flow is meant to be working? Do you understand what each node is meant to be doing?
If something is not behaviour as you think it should, you can use the Debug nodes throughout the flow to see exactly what is happening.
So start with: what does the mysql node return when you pass in E1234562
?