# What are the real possibilities of loading an action.atn file in the Action palette with UXP?

**URL:** <https://forums.creativeclouddeveloper.com/t/what-are-the-real-possibilities-of-loading-an-action-atn-file-in-the-action-palette-with-uxp/6040>\
**Category:** Photoshop\
**Created:** [March 15, 2023, 1:04pm UTC](https://forums.creativeclouddeveloper.com/t/what-are-the-real-possibilities-of-loading-an-action-atn-file-in-the-action-palette-with-uxp/6040 "2023-03-15T13:04:12Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![MalbertCunha](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/malbertcunha/32/2760_2.png) [@MalbertCunha](https://forums.creativeclouddeveloper.com/u/MalbertCunha)\
**Post date:** [March 15, 2023, 1:04pm UTC](https://forums.creativeclouddeveloper.com/t/what-are-the-real-possibilities-of-loading-an-action-atn-file-in-the-action-palette-with-uxp/6040/1 "2023-03-15T13:04:12Z")

</div>

The title says it all, here an unsuccessful attempt.

```auto
async function importarAcao() {
      try {
        const fs = require('uxp').storage.localFileSystem;
        const result = await fs.getFileForOpening({ types: ["atn"] });
        const actionSet = await app.actions.load(result);
        app.actionLists.add(actionSet);
      } catch (err) { console.log(err)}
}
await importarAcao()

```

 ![Captura de tela 2023-03-15 100328](https://us1.discourse-cdn.com/flex015/uploads/xdplugins/original/2X/5/5e40e9a9e689ff131868dc42bff6eb6d9e60eb1e.jpeg)

Any help, whatever it may be, will be greatly appreciated. Thanks!

---

<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:** [March 15, 2023, 1:38pm UTC](https://forums.creativeclouddeveloper.com/t/what-are-the-real-possibilities-of-loading-an-action-atn-file-in-the-action-palette-with-uxp/6040/2 "2023-03-15T13:38:41Z")

</div>

Error clearly states, that `app.actions` is undefined. [Docs](https://developer.adobe.com/photoshop/uxp/2022/ps_reference/classes/photoshop/) say it should be `app.actionTree`, if that’s what you’re looking for.

May I ask where did you find this example with `actions.load()`?

---

<div class="post-metadata">

**Author:** ![MalbertCunha](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/malbertcunha/32/2760_2.png) [@MalbertCunha](https://forums.creativeclouddeveloper.com/u/MalbertCunha)\
**Post date:** [March 15, 2023, 2:13pm UTC](https://forums.creativeclouddeveloper.com/t/what-are-the-real-possibilities-of-loading-an-action-atn-file-in-the-action-palette-with-uxp/6040/3 "2023-03-15T14:13:45Z")

</div>

> [@Karmalakas](#):
>
> May I ask where did you find this example with `actions.load()`?

Tried this based on extendScript, like try

```auto
function loadActions () {
	var actionFile =new File("~/desktop/file.atn");
    if(actionFile.exists){app.load(actionFile)}
};

loadActions ();

```

---

<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:** [March 15, 2023, 2:26pm UTC](https://forums.creativeclouddeveloper.com/t/what-are-the-real-possibilities-of-loading-an-action-atn-file-in-the-action-palette-with-uxp/6040/4 "2023-03-15T14:26:22Z")

</div>

Do not compare ExtendScript with UXP. It’s a completely different thing and probably nothing would work. I personally never developed anything on ExtendScript

---

<div class="post-metadata">

**Author:** ![MalbertCunha](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/malbertcunha/32/2760_2.png) [@MalbertCunha](https://forums.creativeclouddeveloper.com/u/MalbertCunha)\
**Post date:** [March 15, 2023, 2:41pm UTC](https://forums.creativeclouddeveloper.com/t/what-are-the-real-possibilities-of-loading-an-action-atn-file-in-the-action-palette-with-uxp/6040/5 "2023-03-15T14:41:54Z")

</div>

> [@Karmalakas](#):
>
> It’s a completely different thing and probably nothing would work.

This works on both uxp and extendScript

```auto
app.activeDocument.activeLayers[0]
app.foregroundColor.rgb.hexValue

```

I don’t want to get here and why someone write code for me, I try to create my solution, if it doesn’t work, that’s why I turn to this community. Your solution above did not work at all someone who has a lot more knowledge will point me in the right direction. I’m hoping that someone here will point me to a solution that I haven’t seen a solution so far

---

<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:** [March 15, 2023, 3:37pm UTC](https://forums.creativeclouddeveloper.com/t/what-are-the-real-possibilities-of-loading-an-action-atn-file-in-the-action-palette-with-uxp/6040/6 "2023-03-15T15:37:29Z")

</div>

Well… apparently something matches 🙂 Wonder if that was intentional by the devs or just coincidence. In any case, if I understand correctly what you’re trying to do, I don’t think UXP supports that. Did you try checking with [Alchemist](https://github.com/jardicc/alchemist) if there’s some output when you load an action?

---

<div class="post-metadata">

**Author:** ![Jarda](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/jarda/32/1909_2.png) [@Jarda](https://forums.creativeclouddeveloper.com/u/Jarda)\
**Post date:** [March 15, 2023, 3:56pm UTC](https://forums.creativeclouddeveloper.com/t/what-are-the-real-possibilities-of-loading-an-action-atn-file-in-the-action-palette-with-uxp/6040/7 "2023-03-15T15:56:56Z")

</div>

For the loading action, I believe it would same action as when you open file. But instead of “jpg” you would load “atn”. Maybe you could try `open` function in DOM but it might fail because it is designed only to open images and return instance of `Document`.

I will add note to take care of non-image files in `app.open`

---

<div class="post-metadata">

**Author:** ![MalbertCunha](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/malbertcunha/32/2760_2.png) [@MalbertCunha](https://forums.creativeclouddeveloper.com/u/MalbertCunha)\
**Post date:** [March 15, 2023, 7:35pm UTC](https://forums.creativeclouddeveloper.com/t/what-are-the-real-possibilities-of-loading-an-action-atn-file-in-the-action-palette-with-uxp/6040/8 "2023-03-15T19:35:35Z")

</div>

Hi @Jarda thanks for pointing me in the right direction!  
Whether app.open DOM was designed just to open images I don’t know, I just know that it actually loaded the set of actions perfectly and I believe it can also load files: csh, tpl, abr, pat asl etc…

```auto
async function importarAcao() {
      const fs = require('uxp').storage.localFileSystem;
      const result = await fs.getFileForOpening({ types: ["atn"] });
      app.open(result);
}
await importarAcao()

```

---

<div class="post-metadata">

**Author:** ![MalbertCunha](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/malbertcunha/32/2760_2.png) [@MalbertCunha](https://forums.creativeclouddeveloper.com/u/MalbertCunha)\
**Post date:** [March 15, 2023, 8:56pm UTC](https://forums.creativeclouddeveloper.com/t/what-are-the-real-possibilities-of-loading-an-action-atn-file-in-the-action-palette-with-uxp/6040/9 "2023-03-15T20:56:44Z")

</div>

> [@Karmalakas](#):
>
> [Alchemist](https://github.com/jardicc/alchemist)

@Jarda what is the method that checks if an .atn file has already been loaded in the actions palette, I tried to obtain the property in Alchemist, but I only got the number of loaded atn and not the names.

---

<div class="post-metadata">

**Author:** ![Jarda](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/jarda/32/1909_2.png) [@Jarda](https://forums.creativeclouddeveloper.com/u/Jarda)\
**Post date:** [March 15, 2023, 11:06pm UTC](https://forums.creativeclouddeveloper.com/t/what-are-the-real-possibilities-of-loading-an-action-atn-file-in-the-action-palette-with-uxp/6040/10 "2023-03-15T23:06:53Z")

</div>

I would use `validateReference` and then you pass in reference object with ActionSet name in it. If `true` is returned then it is loaded. That is most performant way. Slower but easier way is to use DOM and loop all action sets and search for name match:

---

<div class="post-metadata">

**Author:** ![AnthonyK](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@AnthonyK](https://forums.creativeclouddeveloper.com/u/AnthonyK)\
**Post date:** [March 16, 2023, 12:06am UTC](https://forums.creativeclouddeveloper.com/t/what-are-the-real-possibilities-of-loading-an-action-atn-file-in-the-action-palette-with-uxp/6040/11 "2023-03-16T00:06:30Z")

</div>

You could simply run the action and if it returns an error, load it, and then run it again. If it doesn’t error out, then it’s loaded. Not terribly elegant, I suppose, but I doubt users could tell the difference.

---

<div class="post-metadata">

**Author:** ![Jarda](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/jarda/32/1909_2.png) [@Jarda](https://forums.creativeclouddeveloper.com/u/Jarda)\
**Post date:** [March 16, 2023, 12:24am UTC](https://forums.creativeclouddeveloper.com/t/what-are-the-real-possibilities-of-loading-an-action-atn-file-in-the-action-palette-with-uxp/6040/12 "2023-03-16T00:24:26Z")

</div>

I didn’t try but I don’t think it does work this way.

---

<div class="post-metadata">

**Author:** ![MalbertCunha](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/malbertcunha/32/2760_2.png) [@MalbertCunha](https://forums.creativeclouddeveloper.com/u/MalbertCunha)\
**Post date:** [March 16, 2023, 12:42am UTC](https://forums.creativeclouddeveloper.com/t/what-are-the-real-possibilities-of-loading-an-action-atn-file-in-the-action-palette-with-uxp/6040/13 "2023-03-16T00:42:01Z")

</div>

@Jarda What have you not tested? What are you referring to?  
validate Reference seems like an interesting approach.  
For some reason, even with atn loaded, I always get false as a return;

```auto
console.log(require("photoshop").action.validateReference({_ref: "ActionSet", _name: "myActionsSet"}))

```

@AnthonyK , your suggestion will be very helpful if “validate Reference” definitely doesn’t work. Thanks to both of you for the tips

---

<div class="post-metadata">

**Author:** ![Jarda](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/jarda/32/1909_2.png) [@Jarda](https://forums.creativeclouddeveloper.com/u/Jarda)\
**Post date:** [March 16, 2023, 1:21am UTC](https://forums.creativeclouddeveloper.com/t/what-are-the-real-possibilities-of-loading-an-action-atn-file-in-the-action-palette-with-uxp/6040/14 "2023-03-16T01:21:54Z")

</div>

I was referring to hypothetical the error on the second run.

Maybe you could try to add an application reference as a second item in the reference array to test. It will probably won’t help but there are not much other options remaining 😃

---

<div class="post-metadata">

**Author:** ![MalbertCunha](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/malbertcunha/32/2760_2.png) [@MalbertCunha](https://forums.creativeclouddeveloper.com/u/MalbertCunha)\
**Post date:** [March 16, 2023, 1:42am UTC](https://forums.creativeclouddeveloper.com/t/what-are-the-real-possibilities-of-loading-an-action-atn-file-in-the-action-palette-with-uxp/6040/15 "2023-03-16T01:42:02Z")

</div>

```auto
require("photoshop").action.validateReference({_ref: "ActionSet", _name: "myActionsSet"})

```

Everything was resolved with correction of an error in writing the reference:  
I changed this:

```auto
_ref: "ActionSet"

```

Per:

```auto
_ref: "actionSet"

```

Thank you very much once again!  
If anyone needs this, here’s the code working with existing atn verification!

```auto
async function importAtnFiles() {
      const fs = require('uxp').storage.localFileSystem;
      const action = require("photoshop").action;
      const atnFile = await fs.getFileForOpening({ types: ["atn"] });
      const ActionSetName = action.validateReference({_ref: "actionSet", _name: atnFile.name.match(/(.*)\.[^\.]+$/)[1]})
      if(ActionSetName == true){app.showAlert(`"${atnFile.name}" has already been loaded!`)}
      else{app.open(atnFile);}
}
importAtnFiles()

```

---

<div class="post-metadata">

**Author:** ![PS-fxrios](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/ps-fxrios/32/2461_2.png) [@PS-fxrios](https://forums.creativeclouddeveloper.com/u/PS-fxrios)\
**Post date:** [March 16, 2023, 11:44am UTC](https://forums.creativeclouddeveloper.com/t/what-are-the-real-possibilities-of-loading-an-action-atn-file-in-the-action-palette-with-uxp/6040/16 "2023-03-16T11:44:45Z")

</div>

In my searches I found topics, but without solution.

> [@Load Actions in UXP](http://forums.creativeclouddeveloper.com/t/load-actions-in-uxp/4155):
>
> Hello, Is it possible to load .atn or other actions in uxp. I saw in the documentation only app.actionSet. In CEP I used app.loadAction and app.unloadAction.

> [@Possible to load .atn action file into the Action palette with UXP?](http://forums.creativeclouddeveloper.com/t/possible-to-load-atn-action-file-into-the-action-palette-with-uxp/2338):
>
> Is there a way to load an action file through UXP into the action palette? Say, for example, if there was an .atn file in the plugin folder, it could automatically get loaded into the action palette when the user runs the plugin. If it isn’t possible then that would be a really awesome feature to add slight_smile

> [@Convert an Action into UXP Code (Equivalent of \`XTools\`' \`ActionFileToJavaScript\`)](http://forums.creativeclouddeveloper.com/t/convert-an-action-into-uxp-code-equivalent-of-xtools-actionfiletojavascript/2395):
>
> Hello, Is there an equivalent to XTools’ ActionFileToJavascript? I have an action and I’d like to convert it into UXP batch play. Alchemist generate code which is hard to navigate through and sometimes misses some actions. What about converting JSX function (Executing Action Descriptor) to UXP automatically? Is there anything for that? Happy New Year!

@MalbertCunha thanks for sharing, I was looking for this.
