Can You Use Javascript From CEP Panels In UXP Plugins

I appreciate the Legacy CEP Panels will probably work for at least 12 months maybe longer but at the rate I am learning UXP its going to take me that long to get my head around it :slight_smile: to migrate my CEP Panels over.

In my CEP panel I have a function to check the Channels for a specific Name.

if (app.documents.length > 0) { //we have a document open
    var myDocument = app.activeDocument; //document name
    for (var m = 0; m < myDocument.channels.length; m++) { // Loop through channels 
        var thisChannel = myDocument.channels[m]; //get channel names 
    }

    if (thisChannel.name == "Ref Mask") { // Name your channel
           showAlert("Channel  Exists") ;
           return;
    } 
} 

Is it possible to use these functions I have created in my CEP panels and use them in the new UXP Plugins. I have already tried but cannot get this function to work.

Am I doing something wrong or is it a case that this type of Javascript is not compatible with UXP

Ian

Nope, at least not in this form and not yet. Your code is from the Javascript Reference / Implementation which was provided in CEP.

The new API doesn’t have Channels yet, but the Adobe team is still working on extending it.
For all the cases that aren’t covered by the API yet, you have to stick to BatchPlay (your usecase is definitely possible). Jarda’s Alchemist Plugin is a great starting point to wrap your head around the necessary structure/syntax of the objects you send to or fetch from Photoshop via BatchPlay.

Thanks @simonhenke fo the information.

You said my use case is possible which is encouraging. I do have the Alchemist inspector installed but still trying to establish a workflow with it. Some help files would be nice but I haven’t seen any produced yet

I do have something for support Action Manager code in UXP but this is not yet 100% done. https://github.com/jardicc/am-to-uxp

It could be expanded also on the support of old ExScript API but that would be too much work. And also maybe… maybe Joonas would consider transforming his ScriptUI builder into UXP-UI builder. Since his tools can generate exScript code and also pretend ExScript UI. https://scriptui.joonas.me/