# Custom Code action not copying into Custum Property

**URL:** <https://community.hubspot.com/t/custom-code-action-not-copying-into-custum-property/37221>\
**Category:** Data Hub\
**Created:** [May 12, 2021, 6:20pm UTC](https://community.hubspot.com/t/custom-code-action-not-copying-into-custum-property/37221 "2021-05-12T18:20:53Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![KyleJepson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kylejepson/32/40370_2.png) [@KyleJepson](https://community.hubspot.com/u/KyleJepson)\
**Post date:** [May 13, 2021, 7:46pm UTC](https://community.hubspot.com/t/custom-code-action-not-copying-into-custum-property/37221/9 "2021-05-13T19:46:19Z")

</div>

So I just tried it, and it worked. Here’s what I did:

1. Create a custom deal property called “Ordre Numérique” and make it a number property. (Seems like you already have that step done.)
2. Create your test deal and set it’s “Ordre Numérique” to wherever you want the counting to start, minus one. (So if you want to start at 1, make it 0. If you already have a list of IDs that you want to add to, make it whatever the last one of those is.) For my example, I set the value to 607 (I chose this number at random), so we should expect the first deal to go through the workflow to get a value of 608 (and it did!)
3. Copy the ID of the test deal (you can get that from the URL when you’re on the deal record).
4. Create a deal-based workflow (you can use the one you already have) and set up your enrollment triggers (you’ve already done this). Then add a custom code action and write your code. Here’s the code I came up with:

```lia-code-sample
const hubspot = require('@hubspot/api-client');

exports.main = (event, callback) => {
 callback(processEvent(event));
}

function processEvent(event) {
 const hubspotClient = new hubspot.Client({
 apiKey: process.env.HAPIKEY
 });

 let dealId = event.object.objectId;
 hubspotClient.crm.deals.basicApi.getById("5257315659", ["ordre_numerique"])
 .then(results => {
 let last_order = results.body.properties.ordre_numerique;
 let current_order = ++last_order;
 hubspotClient.crm.deals.basicApi.update(
 dealId,
 {properties: {["ordre_numerique"]: current_order}}
 )
 hubspotClient.crm.deals.basicApi.update(
 "5257315659",
 {properties: {["ordre_numerique"]: current_order}}
 ) 
 })
}

```

Now, don’t just copy-paste this code and expect it to work! Here are some notes:

1. process.env.HAPIKEY

HAPIKEY

with whatever you call your secret (unless you call it HAPIKEY).

1. 5257315659

5257315659

in this code.

1. ordre\_numerique

And that’s it. I’ve run three deals through this workflow in my own account, and the first one was given number 608, then the next one was given 609, and the third one was giving 610, which I think is exactly what you were going for.

Let me know if you have any trouble with it!

Kyle

---

_[View the full topic](https://community.hubspot.com/t/custom-code-action-not-copying-into-custum-property/37221)._
