# Increment a state variable in payload format Converter

**URL:** <https://www.thethingsnetwork.org/forum/t/increment-a-state-variable-in-payload-format-converter/39427>\
**Category:** Application Development\
**Created:** [August 24, 2020, 12:21pm UTC](https://www.thethingsnetwork.org/forum/t/increment-a-state-variable-in-payload-format-converter/39427 "2020-08-24T12:21:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![iot-payload](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/iot-payload/32/35697_2.png) [@iot-payload](https://www.thethingsnetwork.org/forum/u/iot-payload)\
**Post date:** [August 24, 2020, 12:21pm UTC](https://www.thethingsnetwork.org/forum/t/increment-a-state-variable-in-payload-format-converter/39427/1 "2020-08-24T12:21:27Z")

</div>

Hi guys,  
I’ve need a increment variable in function Convert(decoded, port), is possible?  
Actually at every access is resetting…

Thanks a lot  
Stefano

---

<div class="post-metadata">

**Author:** ![arjanvanb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjanvanb/32/46626_2.png) [@arjanvanb](https://www.thethingsnetwork.org/forum/u/arjanvanb)\
**Post date:** [August 24, 2020, 3:59pm UTC](https://www.thethingsnetwork.org/forum/t/increment-a-state-variable-in-payload-format-converter/39427/2 "2020-08-24T15:59:04Z")

</div>

Not possible; you only get the decoded application payload and the port number, and cannot preserve any state. It’s also not possible in the Decoder function.

See also:

- [Access to previous data in Payload format](https://www.thethingsnetwork.org/forum/t/access-to-previous-data-in-payload-format/22384)
- [How can i do a condition using two uplink messages?](https://www.thethingsnetwork.org/forum/t/how-can-i-do-a-condition-using-two-uplink-messages/37042)
- [Access Metadata in decoder](https://www.thethingsnetwork.org/forum/t/access-metadata-in-decoder/19118)
- [Payload Formats [HowTo] - #3 by arjanvanb](https://www.thethingsnetwork.org/forum/t/payload-functions-howto/3441/3)

So, you’ll need to keep state on your application server, or use some third-party server. For Node-RED see [Working with context](https://nodered.org/docs/user-guide/context). For Pipedream, see [`$checkpoint` in Workflow state](https://docs.pipedream.com/workflows/steps/code/state/).

And beware:

> [@Convert custom payload to lpp payload in TTN console](https://www.thethingsnetwork.org/forum/t/convert-custom-payload-to-lpp-payload-in-ttn-console/12171/9):
>
> We’re dropping the converter and validator in V3 as they’re not being used; you can put conversion in the decoder, and it makes more sense to drop/filter out invalid values higher upstream.
