# Create a new value from another value

**URL:** <https://discourse.nodered.org/t/create-a-new-value-from-another-value/87768>\
**Category:** General\
**Created:** [7 May 2024 08:24 UTC](https://discourse.nodered.org/t/create-a-new-value-from-another-value/87768 "2024-05-07T08:24:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pierredemay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pierredemay/32/90948_2.png) [@pierredemay](https://discourse.nodered.org/u/pierredemay)\
**Post date:** [7 May 2024 08:24 UTC](https://discourse.nodered.org/t/create-a-new-value-from-another-value/87768/1 "2024-05-07T08:24:44Z")

</div>

Hello there,

This is my object :  
 ![Capture d’écran 2024-05-07 à 10.10.25](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/d/1da16c5480f33741cce67e47ccf967edc53e7e6c.png)

My goal is to set the value of **Numero** like this : BCUSA24PR04152024  
Keep in mind that the last 8 caracters (04152024) is based on the value of **Date**.

Can someone help me to do this ?

Thanks !

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [7 May 2024 09:17 UTC](https://discourse.nodered.org/t/create-a-new-value-from-another-value/87768/2 "2024-05-07T09:17:23Z")

</div>

> [@pierredemay](#):
>
> BCUSA24PR04152024

you might want to use the change node with a Jsonata expression, something like the follow flow:

```auto
[{"id":"9f18f65b9f1c09fb","type":"inject","z":"42e3d9cace994979","name":"","props":[{"p":"payslip","v":"{\"Numero\":0,\"Date\":\"15/04/2123\",\"Code Journal\":\"GS\",\"Exercise\":234}","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":855.1428833007812,"y":817.7142944335938,"wires":[["89b5f7eb75d15a3d","7a1dcb12dda9c30e"]]},{"id":"89b5f7eb75d15a3d","type":"change","z":"42e3d9cace994979","name":"","rules":[{"t":"set","p":"payslip.Numero","pt":"msg","to":"\"BCUSA24PR\" & $replace( $$.payslip.Date, \"/\", \"\")\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1220,"y":819,"wires":[["8d90c064c9fb345c"]]},{"id":"8d90c064c9fb345c","type":"debug","z":"42e3d9cace994979","name":"Changed Value","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payslip","targetType":"msg","statusVal":"","statusType":"auto","x":1583,"y":933,"wires":[]},{"id":"7a1dcb12dda9c30e","type":"debug","z":"42e3d9cace994979","name":"Original Value","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payslip","targetType":"msg","statusVal":"","statusType":"auto","x":1164,"y":700,"wires":[]}]

```

Edit: updated the flow to be correct and use Jsonata.

---

<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 August 2024 09:18 UTC](https://discourse.nodered.org/t/create-a-new-value-from-another-value/87768/3 "2024-08-05T09:18:02Z")

</div>

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