Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
1

Help with the new UXP createInsertProjectItemAction() method. "Script Action failed to execute"

Community Beginner ,
Mar 29, 2025 Mar 29, 2025

Hi. I've been trying to use the new UXP createInsertProjectItemAction() method to insert a clip into my main sequence's timeline, but I can't seem to get it to work. I'm getting the following error ("Script Action failed to execute."):

 

Screenshot 2025-03-29 at 12.36.39 PM.pngexpand image

Here's the Adobe documentation page for that method.

 

Here's a sample with all of the required parameters:

SequenceEditor.createInsertProjectItemAction(projectItem, TickTime, videoTrackIndex, audioTrackIndex, limitShift);

 

Below is the entirety of my code. The error happens at line 19, and execution of the script stops before it even gets to the executeAction() function (line 29), so I don't think that's the problem. For context, my Premiere project just consists of a sequence called "Main Sequence" and a video clip called "Iceberg.MOV".

 

1  const ppro = require("premierepro");
2 
3  async function insertItem() {
4    try {
5         const project = await ppro.Project.getActiveProject();
6         const rootItem = await project.getRootItem();
7         const items = await rootItem.getItems();
8         const mainSequence = await project.getActiveSequence();
9         const editor = await ppro.SequenceEditor.getEditor(mainSequence);
10        const insertionTime = await ppro.TickTime.createWithSeconds(2);
11        var itemToInsert;
12        
13        // Specify the item you want to insert into the timeline
14        items.forEach(element => {
15            if (element.name == "Iceberg.MOV") itemToInsert = element;
16        });
17
18        // Create the insertion Action
19        actInsertProjItem = await editor.createInsertProjectItemAction(itemToInsert, insertionTime, 1, 1, false);
20        
21        // Execute the insertion Action
22        executeAction(project, actInsertProjItem);
23
24    } catch (err) {
25        console.error(err);
26    }
27  }
28
29  function executeAction(project, theAction) {
30     try {
31        project.lockedAccess(() => {
32            project.executeTransaction ((compoundAction) => {
33                compoundAction.addAction(theAction);
34            })
35        });
36    } catch (err) {
37        console.error(err);
38    }
39  }
40
41  document.querySelector("#btnPopulate").addEventListener("click", insertItem);

 

Things I've already investigated:

  • Checked to make sure I'm running the latest version of the Premiere Pro beta app (25.3.0 build 33).
  • My seqEditor variable is of the right type (SequenceEditor object).
  • All of the parameters passed in the createInsertProjectItemAction() method are of the right type (projectItem, TickTime, numbers, booleans).
  • Tried changing the values of the videoTrackIndex, audioTrackIndex parameters to different numbers.
  • Tried changing the value of the limitShift parameter (true/false, 0/1 etc).
  • Tried different types of items to insert (video clip, sequence, adjustment layer, color matte etc).
  • I've also tried searching online for help, but Google literally returns zero pages discussing this method except for the Adobe documentation page and a Creative Cloud Developer forum page announcing its release 10 days ago (March 19, 2025).

 

If you have any ideas on how I can get it to work, or if you can spot any errors in my code please let me know. Thanks!

TOPICS
How to , SDK
168
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Employee , Mar 31, 2025 Mar 31, 2025

createInsertProjectItemAction() works great in the sample plugin, so we're hopeful you can get this to work...

 

What happens in your case, if you pass ppro.TickTime.TIME_ZERO as the insertion time? 

Translate
Adobe Employee ,
Mar 31, 2025 Mar 31, 2025

createInsertProjectItemAction() works great in the sample plugin, so we're hopeful you can get this to work...

 

What happens in your case, if you pass ppro.TickTime.TIME_ZERO as the insertion time? 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 31, 2025 Mar 31, 2025

Hi @Bruce Bullis 

 

Thanks for your quick reply! I tried using ppro.TickTime.TIME_ZERO as the insertion time,  but I got the same error (Script action failed to execute.)

 

Can you point me to where I can find the sample plugin you mentioned? I'd love to take a look at that code and compare it to mine.

 

Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 31, 2025 Mar 31, 2025

Nevermind, I found it.

 

In case anyone else is wondering, it can be found at this github repository.

 

I'll report back whether or not I'm able to get it working.

 

Thank you

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 31, 2025 Mar 31, 2025
LATEST

I found the sample code and I was able to get it to work!

 

Previously, I tried to execute the createInsertProjectItemAction() method and assign it to a variable first, then pass that variable into my executeAction() function, then into the executeTransaction() method.

 

But it seems that the createInsertProjectItemAction() method only works correctly when nested inside of the project.executeTransaction() method.

 

Below is my working code:

const app = require("premierepro");

// Insert a specified item into the main timeline
async function insertItem() {
    try {
        const project = await app.Project.getActiveProject();
        const rootItem = await project.getRootItem();
        const items = await rootItem.getItems();
        const mainSequence = await project.getActiveSequence();
        const seqEditor = await app.SequenceEditor.getEditor(mainSequence);
        const insertionTime = await app.TickTime.createWithSeconds(3);
        const onlyShiftInputTrack = true; // False = split & shift ALL tracks at insertion point
        var itemToInsert;

        // Specify item to insert
        for (i=0; i<items.length; i++) {
            if (items[i].name == "Iceberg.MOV") {
                itemToInsert = items[i];
                break;
            }
        }

        // Create & Execute the Insertion Action
        project.lockedAccess(() => {
            project.executeTransaction ((compoundAction) => {
                actInsertProjItem = seqEditor.createInsertProjectItemAction(itemToInsert, insertionTime, 0, 0, onlyShiftInputTrack);
                compoundAction.addAction(actInsertProjItem);
            })
        });

    } catch (err) {
        console.error(err);
    }
}

document.querySelector("#btnPopulate").addEventListener("click", insertItem);

 

 Thanks for your help!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines