Quantcast
Channel: Adobe Community : Popular Discussions - InDesign Scripting
Viewing all articles
Browse latest Browse all 15932

event scripting issues

$
0
0

I am trying to get the following script working as a startup script.

 

the goal is that when the user chooses to save the document, they are presented with a dialog box asking for a quick summary of the edits that were made. Then this info is written to XMP fields.

 

The core functionality actually works, the dialog prompts and the data gets saved in the XMP.

 

The problem is that when the save action is initiated an error dialog pops up announcing "The requested action could not be completed because the object no longer exists." and then the script proceeds and functions properly, then it prompts for input and saves the data again.

 

I get an error, then the script runs twice.

 

I am confused.

 

 

 

#targetengine session

var myEventListener = app.addEventListener("beforeSave", myPromptForInput);

 

function myPromptForInput(myEvent){

var myTimeStamp = myEvent.timeStamp

var myDialog = app.dialogs.add({name:"Enter a simple description of edits made",canCancel:true});

with(myDialog){

//Add a dialog column.

with(dialogColumns.add()){

//Create a text edit field.

var myTextEditField = textEditboxes.add({editContents:"Description of document changes", minWidth:300});

//Display the dialog box.

var myResult = myDialog.show();

if(myResult == true){

//Get the values from the dialog box controls.

var myNotes = myTextEditField.editContents;

//Remove the dialog box from memory.

myDialog.destroy();

myAddXMPData(myNotes + " - " + myTimeStamp);

//alert(myEvent);

}

}

}

}

 

function myAddXMPData(myNotes){ 

//var myDocument = app.documents.item(0);

var myDocument = app.activeDocument;

with(myDocument.metadataPreferences){

author = "James Haney";

description = myNotes;

var myNewContainer = createContainerItem("http://ns.adobe.com/xap/1.0/", "LCCRevisionNotes");

setProperty("http://ns.adobe.com/xap/1.0/", "LCCRevisionNotes/*[1]", myNotes);

}

}


Viewing all articles
Browse latest Browse all 15932

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>