# Create many s7 node entries

**URL:** <https://discourse.nodered.org/t/create-many-s7-node-entries/78482>\
**Category:** Industrial\
**Created:** [17 May 2023 05:44 UTC](https://discourse.nodered.org/t/create-many-s7-node-entries/78482 "2023-05-17T05:44:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Loveflowersx](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@Loveflowersx](https://discourse.nodered.org/u/Loveflowersx)\
**Post date:** [17 May 2023 05:44 UTC](https://discourse.nodered.org/t/create-many-s7-node-entries/78482/1 "2023-05-17T05:44:50Z")

</div>

Hello everybody,

I want to create a lot of variables from TIA Portal to Node-RED, but there are a lot of them. I can export .json the node and create several, I am trying to do it from excel but it is a lot of concatenation.

Or how can I read 200 boolean variables from a data block and then have that variable set to true so I can manage it to send an email referring to that variable?

What can I do?

![variables](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/b/7b0ee0058680d01488cb518f214d16c7d215f8aa.png)

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![KarolisL](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@KarolisL](https://discourse.nodered.org/u/KarolisL)\
**Post date:** [17 May 2023 17:31 UTC](https://discourse.nodered.org/t/create-many-s7-node-entries/78482/2 "2023-05-17T17:31:09Z")

</div>

Hello, can't you just read all variables at once and then parse it to your requirements?  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/d/9d63d8ef8972f23eda63c4fe083f6be6de220fda.png)  
to create all variables you can import csv file, so you don't have to do one by one  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/a/1a119ee68effb81011c598923b3c6fb0f71718f1.png)

---

<div class="post-metadata">

**Author:** ![Loveflowersx](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@Loveflowersx](https://discourse.nodered.org/u/Loveflowersx)\
**Post date:** [22 May 2023 06:39 UTC](https://discourse.nodered.org/t/create-many-s7-node-entries/78482/3 "2023-05-22T06:39:53Z")

</div>

And how do I analyse according to the requirements, for example if it is true or false, if there are two hundred boolean variables, and show the ones that are true.

Thank you very much

---

<div class="post-metadata">

**Author:** ![KarolisL](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@KarolisL](https://discourse.nodered.org/u/KarolisL)\
**Post date:** [22 May 2023 07:19 UTC](https://discourse.nodered.org/t/create-many-s7-node-entries/78482/4 "2023-05-22T07:19:51Z")

</div>

Hello, lets do it one step at the time...  
1.please read all variables in single node instead of separate one by one.  
2.Msg.payload will look like: `Tag1: true, Tag2: false, Tag3: false, Tag4: true, Tag5: false`  
3.Then based on this object you filter the tags that you want to use and send it in email

---

<div class="post-metadata">

**Author:** ![Loveflowersx](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@Loveflowersx](https://discourse.nodered.org/u/Loveflowersx)\
**Post date:** [22 May 2023 10:17 UTC](https://discourse.nodered.org/t/create-many-s7-node-entries/78482/5 "2023-05-22T10:17:14Z")

</div>

What I do for individual nodes, I store the variable s7 in this function  
flow.set('ALR\_Dif\_relay',msg.payload)  
return msg;

Then in another node function  
var ALR\_Dif\_relay = flow.get('ALR\_Dif\_relay');

and then a conditional that if true, is stored in a variable and a message and sent in a mail, so with several variables together.

My question is how do I collect all those variables that are true, and put them as a body for an email.

Thank you very much for answering

---

<div class="post-metadata">

**Author:** ![KarolisL](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@KarolisL](https://discourse.nodered.org/u/KarolisL)\
**Post date:** [22 May 2023 10:58 UTC](https://discourse.nodered.org/t/create-many-s7-node-entries/78482/6 "2023-05-22T10:58:45Z")

</div>

```auto
[{"id":"b07cd5d8a9884a8e","type":"function","z":"279d0ea8.c23d82","name":"FilterTrueTags","func":"function filterTrueTags(tags) {\n return Object.keys(tags).filter(key => tags[key] === true);\n}\n\nconst tags = msg.payload\n\nmsg.payload = filterTrueTags(tags)\n\nreturn msg\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":460,"y":560,"wires":[["3b62b96a624b4f6c"]]},{"id":"b3df672959fdad08","type":"inject","z":"279d0ea8.c23d82","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"Tag1\":true,\"Tag2\":false,\"Tag3\":false,\"Tag4\":true,\"Tag5\":false,\"NewTag0\":false,\"OldTag1\":true}","payloadType":"json","x":290,"y":560,"wires":[["b07cd5d8a9884a8e"]]},{"id":"3b62b96a624b4f6c","type":"debug","z":"279d0ea8.c23d82","name":"debug 285","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":650,"y":560,"wires":[]}]

```

This way you will filter out variables which are true,  
Then you can do whatever you want to do - iterate over it and create the string you want and forward it to email

---

<div class="post-metadata">

**Author:** ![Loveflowersx](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@Loveflowersx](https://discourse.nodered.org/u/Loveflowersx)\
**Post date:** [22 May 2023 12:59 UTC](https://discourse.nodered.org/t/create-many-s7-node-entries/78482/7 "2023-05-22T12:59:15Z")

</div>

It worked, thank you very much!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [5 June 2023 12:59 UTC](https://discourse.nodered.org/t/create-many-s7-node-entries/78482/8 "2023-06-05T12:59:22Z")

</div>

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