# Alchemist help needed

**URL:** <https://forums.creativeclouddeveloper.com/t/alchemist-help-needed/2781>\
**Category:** UXP Plugin API\
**Created:** [April 11, 2021, 1:21pm UTC](https://forums.creativeclouddeveloper.com/t/alchemist-help-needed/2781 "2021-04-11T13:21:51Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![pdophoto](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/pdophoto/32/1304_2.png) [@pdophoto](https://forums.creativeclouddeveloper.com/u/pdophoto)\
**Post date:** [April 11, 2021, 1:21pm UTC](https://forums.creativeclouddeveloper.com/t/alchemist-help-needed/2781/1 "2021-04-11T13:21:51Z")

</div>

Hi everyone,  
I have problems making functions from code generated by Alchemist. +/- 90% of the time **“IT DOESN’T WORK”** 🥵  
So what is wrong with the following or more probably what did I do wrong:

**Top of index.js**  
var batchPlay = require(“photoshop”).action.batchPlay;  
const app = require(‘photoshop’).app;  
const docPath = app.activeDocument.path;

**The function:**  
var saveTIF = async () =\> {  
//async function saveTIF () {  
await batchPlay(  
[  
{  
“\_obj”: “save”,  
“as”: {  
“\_obj”: “TIFF”,  
“byteOrder”: {  
“\_enum”: “platform”,  
“\_value”: “IBMPC”  
}  
},  
“in”: {  
“\_path”: “D:\\Entrepot\\LR-PE\\UXP\\Tools3\\Panel.tif”,  
“\_kind”: “local”  
},  
“documentID”: 654,  
“lowerCase”: true,  
“saveStage”: {  
“\_enum”: “saveStageType”,  
“\_value”: “saveBegin”  
},  
“\_isCommand”: false,  
“\_options”: {  
“dialogOptions”: “dontDisplay”  
}  
}  
],{  
“synchronousExecution”: false,  
“modalBehavior”: “fail”  
});  
}

---

<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:** [April 11, 2021, 10:06pm UTC](https://forums.creativeclouddeveloper.com/t/alchemist-help-needed/2781/2 "2021-04-11T22:06:46Z")

</div>

> [@pdophoto](#):
>
> “\_path”: “D:\Entrepot\LR-PE\UXP\Tools3\Panel.tif”,

One obvious issue is that you have to use tokens instead of paths when saving files using UXP. Do a search for “token” in this forum and you’ll see several posts that address this issue.

---

<div class="post-metadata">

**Author:** ![pdophoto](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/pdophoto/32/1304_2.png) [@pdophoto](https://forums.creativeclouddeveloper.com/u/pdophoto)\
**Post date:** [April 11, 2021, 10:20pm UTC](https://forums.creativeclouddeveloper.com/t/alchemist-help-needed/2781/3 "2021-04-11T22:20:34Z")

</div>

Thanks, I will search the forum.

---

<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:** [April 11, 2021, 10:21pm UTC](https://forums.creativeclouddeveloper.com/t/alchemist-help-needed/2781/4 "2021-04-11T22:21:16Z")

</div>

Yes I didn’t implement support for

- file-path data type (this could be possible to do but it is not that easy)
- raw data type (there is no information on whether this data type is implemented or how to use it so I don’t know what to generate) Adobe: please tell us how to deal with it.

---

<div class="post-metadata">

**Author:** ![pdophoto](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/pdophoto/32/1304_2.png) [@pdophoto](https://forums.creativeclouddeveloper.com/u/pdophoto)\
**Post date:** [April 11, 2021, 11:19pm UTC](https://forums.creativeclouddeveloper.com/t/alchemist-help-needed/2781/5 "2021-04-11T23:19:35Z")

</div>

Thanks for the information. If it was the only thing that I can not implement from Alchemist listing, that would only be an inconvenient. I can not implement simple things like tools.  
I have over 200 buttons, 4 sliders & 125 jsx files for this panel. If I can not port these I will have to use Photoshop 2021 to have access to my 4 panels. There must be something I am doing wrong or not doing.  
Well, back to work and thanks again.

---

<div class="post-metadata">

**Author:** ![pdophoto](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/pdophoto/32/1304_2.png) [@pdophoto](https://forums.creativeclouddeveloper.com/u/pdophoto)\
**Post date:** [April 12, 2021, 3:05pm UTC](https://forums.creativeclouddeveloper.com/t/alchemist-help-needed/2781/6 "2021-04-12T15:05:42Z")

</div>

Problem solved at 90% for saving an open document at the touch of a button:  
Get folder key, Create file, Get file key and Save the document format tif

The purpose behind my panel is to save clicks or click a button and the job is done.  
So how to eliminate the need to re-select the folder?

// Save open document as tif  
const zz = async () =\> {  
var doc = app.activeDocument;  
const docPath = app.activeDocument.path;  
var fin = docPath.length - docPath.lastIndexOf("\") - 1 - 4;  
var debut = docPath.lastIndexOf("\")+1  
const docName = docPath.substr(debut, fin);  
const pathNoExt = docPath.substr(0, docPath.length-4);  
const docPathShort = docPath.substr(0, docPath.lastIndexOf("\"));

// Get folder key  
var saveFolder = await require(“uxp”).storage.localFileSystem.getFolder(docPathShort);  
// Create file  
var saveFile = await saveFolder.createFile(docName+".tif");  
// get file key  
var saveFileToken = await require(“uxp”).storage.localFileSystem.createSessionToken(saveFile);

// Save the flie why re-select the folder  
await saveTIF(saveFileToken);

async function saveTIF(fileToken){

const batchPlay = require(“photoshop”).action.batchPlay;

await batchPlay(  
[  
{  
“\_obj”: “save”,  
“as”: {  
“\_obj”: “TIFF”,  
“byteOrder”: {  
“\_enum”: “platform”,  
“\_value”: “IBMPC”  
},  
“LZWCompression”: true,  
“saveTransparency”: true,  
“layerCompression”: {  
“\_enum”: “encoding”,  
“\_value”: “RLE”  
}  
},  
“in”: {  
“\_path”: fileToken,  
“\_kind”: “local”  
},  
“saveStage”: {  
“\_enum”: “saveStageType”,  
“\_value”: “saveBegin”  
},  
“\_isCommand”: false,  
“\_options”: {  
“dialogOptions”: “dontDisplay”  
}  
}  
],{  
“synchronousExecution”: false,  
“modalBehavior”: “fail”  
});  
}  
}

---

<div class="post-metadata">

**Author:** ![tomzag](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/tomzag/32/2464_2.png) [@tomzag](https://forums.creativeclouddeveloper.com/u/tomzag)\
**Post date:** [April 12, 2021, 5:29pm UTC](https://forums.creativeclouddeveloper.com/t/alchemist-help-needed/2781/7 "2021-04-12T17:29:04Z")

</div>

Instead of a session token you can create, save and load a [persistent token](https://adobexdplatform.com/plugin-docs/reference/uxp/module/storage.html#createpersistenttokenentry).

Seems to be documented only for XD but works also for Photoshop:

---

<div class="post-metadata">

**Author:** ![pdophoto](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/pdophoto/32/1304_2.png) [@pdophoto](https://forums.creativeclouddeveloper.com/u/pdophoto)\
**Post date:** [April 12, 2021, 5:30pm UTC](https://forums.creativeclouddeveloper.com/t/alchemist-help-needed/2781/8 "2021-04-12T17:30:46Z")

</div>

Thanks, I will try it right now

---

<div class="post-metadata">

**Author:** ![kerrishotts](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/kerrishotts/32/8_2.png) [@kerrishotts](https://forums.creativeclouddeveloper.com/u/kerrishotts)\
**Post date:** [April 13, 2021, 12:57am UTC](https://forums.creativeclouddeveloper.com/t/alchemist-help-needed/2781/9 "2021-04-13T00:57:30Z")

</div>

It’s doc’d here for PS: [https://www.adobe.io/photoshop/uxp/uxp/reference-js/Modules/uxp/Persistent%20File%20Storage/FileSystemProvider/#createpersistenttokenentry](https://www.adobe.io/photoshop/uxp/uxp/reference-js/Modules/uxp/Persistent%20File%20Storage/FileSystemProvider/#createpersistenttokenentry)

---

<div class="post-metadata">

**Author:** ![tomzag](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/tomzag/32/2464_2.png) [@tomzag](https://forums.creativeclouddeveloper.com/u/tomzag)\
**Post date:** [April 13, 2021, 9:05am UTC](https://forums.creativeclouddeveloper.com/t/alchemist-help-needed/2781/10 "2021-04-13T09:05:14Z")

</div>

Thanks Kerri. Then it seems the search function is not working properly. I searched for `createPersistentToken` and it gave me no results.

---

<div class="post-metadata">

**Author:** ![kerrishotts](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/kerrishotts/32/8_2.png) [@kerrishotts](https://forums.creativeclouddeveloper.com/u/kerrishotts)\
**Post date:** [April 13, 2021, 3:24pm UTC](https://forums.creativeclouddeveloper.com/t/alchemist-help-needed/2781/11 "2021-04-13T15:24:49Z")

</div>

Yeah; the search is not good right now. We’re hoping that we can improve it soon.
