# Change value of "textKey" in Text Layer

**URL:** <https://forums.creativeclouddeveloper.com/t/change-value-of-textkey-in-text-layer/3129>\
**Category:** Photoshop\
**Created:** [June 21, 2021, 7:54am UTC](https://forums.creativeclouddeveloper.com/t/change-value-of-textkey-in-text-layer/3129 "2021-06-21T07:54:56Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saint\_Jung](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@Saint\_Jung](https://forums.creativeclouddeveloper.com/u/Saint_Jung)\
**Post date:** [June 21, 2021, 7:54am UTC](https://forums.creativeclouddeveloper.com/t/change-value-of-textkey-in-text-layer/3129/1 "2021-06-21T07:54:56Z")

</div>

Hi. I have a newbie question.

I’m trying to change the value of some text layer by batch play.  
I have “layerID” of the target layer.

I can get this result if I change a value manually w/ alchemist listener is on.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/xdplugins/original/2X/0/0ab484520c6117875901264a0deb6d90b50bd478.png)

So, I made a function like this but it returns error ☹

```
await batchPlay(
    [{
        "_obj": "set",
        "_target": [
            {
                "_ref": "textLayer",
                "_enum": "ordinal",
                "_value": "targetEnum",
                "_id": parseInt(layerID)
            }
        ],
        "to": [{
            "_obj": "textLayer",
            "textKey": transString
            }],
        "_isCommand": false,
        "_options": {
            "dialogOptions": "dontDisplay"
        }
    }], {
        "synchronousExecution": true,
    });

```

How can I fix this?

---

<div class="post-metadata">

**Author:** ![Karmalakas](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/karmalakas/32/1048_2.png) [@Karmalakas](https://forums.creativeclouddeveloper.com/u/Karmalakas)\
**Post date:** [June 21, 2021, 8:02am UTC](https://forums.creativeclouddeveloper.com/t/change-value-of-textkey-in-text-layer/3129/2 "2021-06-21T08:02:23Z")

</div>

I believe this is the problem:

> [@Saint\_Jung](#):
>
> ```auto
> {
> "_ref": "textLayer",
> "_enum": "ordinal",
> "_value": "targetEnum",
> "_id": parseInt(layerID)
> }
> 
> ```

* * *

If you want to change current active layer, you do it like:

```auto
            {
                "_ref": "textLayer",
                "_enum": "ordinal",
                "_value": "targetEnum"
            }

```

If you want to change a specific layer by ID:

```auto
            {
                "_ref": "textLayer",
                "_id": parseInt(layerID)
            }

```

Or by name, IIRC:

```auto
            {
                "_ref": "textLayer",
                "_name": "Layer name"
            }

```

---

<div class="post-metadata">

**Author:** ![Saint\_Jung](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@Saint\_Jung](https://forums.creativeclouddeveloper.com/u/Saint_Jung)\
**Post date:** [June 21, 2021, 8:07am UTC](https://forums.creativeclouddeveloper.com/t/change-value-of-textkey-in-text-layer/3129/3 "2021-06-21T08:07:03Z")

</div>

Thank you for your quick response!

I’ve tried the second one, but still crashing ☹  
{  
“\_ref”: “textLayer”,  
“\_id”: parseInt(layerID)  
}

---

<div class="post-metadata">

**Author:** ![Karmalakas](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/karmalakas/32/1048_2.png) [@Karmalakas](https://forums.creativeclouddeveloper.com/u/Karmalakas)\
**Post date:** [June 21, 2021, 8:07am UTC](https://forums.creativeclouddeveloper.com/t/change-value-of-textkey-in-text-layer/3129/4 "2021-06-21T08:07:55Z")

</div>

What’s the error? You could check it in console

---

<div class="post-metadata">

**Author:** ![Saint\_Jung](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@Saint\_Jung](https://forums.creativeclouddeveloper.com/u/Saint_Jung)\
**Post date:** [June 21, 2021, 8:13am UTC](https://forums.creativeclouddeveloper.com/t/change-value-of-textkey-in-text-layer/3129/5 "2021-06-21T08:13:25Z")

</div>

Nothing is printed in debug console.  
just error message box is appeared like this.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/xdplugins/original/2X/8/89c5089711d275e81f071dd2c48eabd6f027f90d.png)  
it’s “could not complete your request because of a program error” in Korean version

---

<div class="post-metadata">

**Author:** ![Karmalakas](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/karmalakas/32/1048_2.png) [@Karmalakas](https://forums.creativeclouddeveloper.com/u/Karmalakas)\
**Post date:** [June 21, 2021, 8:19am UTC](https://forums.creativeclouddeveloper.com/t/change-value-of-textkey-in-text-layer/3129/6 "2021-06-21T08:19:19Z")

</div>

Could you check the “Code” tab in Alchemist when you make the change? It generates the exact code to run with BatchPlay. See if that works

---

<div class="post-metadata">

**Author:** ![Saint\_Jung](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@Saint\_Jung](https://forums.creativeclouddeveloper.com/u/Saint_Jung)\
**Post date:** [June 21, 2021, 8:31am UTC](https://forums.creativeclouddeveloper.com/t/change-value-of-textkey-in-text-layer/3129/7 "2021-06-21T08:31:58Z")

</div>

Wow!  
I found the reason thanks to your advice!  
There should not “[”, “]” in the “to” section.

Thank you so much!!

---

<div class="post-metadata">

**Author:** ![mateszkom](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/mateszkom/32/1580_2.png) [@mateszkom](https://forums.creativeclouddeveloper.com/u/mateszkom)\
**Post date:** [July 1, 2021, 11:54am UTC](https://forums.creativeclouddeveloper.com/t/change-value-of-textkey-in-text-layer/3129/8 "2021-07-01T11:54:07Z")

</div>

Wben i execute that code my text sometimes reduces size like 4x. Idk why it is inconsistent
