# Change data in inject

**URL:** <https://discourse.nodered.org/t/change-data-in-inject/23161>\
**Category:** General\
**Created:** [16 March 2020 07:07 UTC](https://discourse.nodered.org/t/change-data-in-inject/23161 "2020-03-16T07:07:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mastin](https://avatars.discourse-cdn.com/v4/letter/m/90db22/32.png) [@Mastin](https://discourse.nodered.org/u/Mastin)\
**Post date:** [16 March 2020 07:07 UTC](https://discourse.nodered.org/t/change-data-in-inject/23161/1 "2020-03-16T07:07:39Z")

</div>

Hello, sorry if this does not go here, but I am very new to this.

I have a doubt that I have not been able to solve by myself.

I have an inject to a "socketcan -in" as I show in the attachment.  
 ![1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/6/a6b2ee63a1a6250639b486a643afebdfb936e59c.jpeg)

that inject sends this json

```auto
{
    "ext": false,
    "rtr": false,
    "canid": 123,
    "dlc": 5,
    "data": [
        1,
        2,
        3,
        4,
        5
    ]
}

```

My question is. if I can individually vary the values ​​of "data" (1,2,3,4,5 ...) from a text box or similar and send it modified to the socketcan.

Thanks in advanced!

---

<div class="post-metadata">

**Author:** ![techraf](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/techraf/32/17389_2.png) [@techraf](https://discourse.nodered.org/u/techraf)\
**Post date:** [16 March 2020 10:03 UTC](https://discourse.nodered.org/t/change-data-in-inject/23161/2 "2020-03-16T10:03:00Z")

</div>

Of course you can, but you need to use `numeric` or `text input` node―or whatever suits your requirement: "_individually vary the values_"―in the dashboard.

Replace your `inject` with `change` and use a JSONata expression to merge the user-provided values accordingly into the JSON you require.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [16 March 2020 15:59 UTC](https://discourse.nodered.org/t/change-data-in-inject/23161/3 "2020-03-16T15:59:06Z")

</div>

If you have a lot of numbers to input (or maybe a variable number of inputs) and need to create form for them, you can also use the ui-template Dashboard node and use the features of the underlying Angular framework. `ng-repeat` will let you dynamically build any HTML/Angular structure including multiple input boxes.

Alternatively, you could us a single textbox input and collect the numbers as a string then parse that string either using a function node or a change node with the JSONata `split` function.

`"1,2,3,4,....,99"`

JSONata in a change node:

```auto
$split(payload, ',')

```

Which should return an array from the original string.

---

<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:** [15 May 2020 15:59 UTC](https://discourse.nodered.org/t/change-data-in-inject/23161/4 "2020-05-15T15:59:23Z")

</div>

Closed on 15 May 2020 15:59 UTC

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