These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

myAnnot.transitionToState is not a function??

lithodora
Registered: Sep 9 2008
Posts: 5

I am simply trying to add toolbar buttons to allow users to Accept or Reject Commenting Annotations in a PDF.

function approve()
{
var myAnnot = this.selectedAnnots;
myAnnot.transitionToState("ReviewStates", "accepted");
}
 
function reject()
{
var myAnnot = this.selectedAnnots;
myAnnot.transitionToState("ReviewStates", "rejected");
}
 
app.addToolButton({
cName: "Approved",
cExec: "approve();",
cTooltext: "approved",
nPos: 0
});
app.addToolButton({
cName: "Rejected",
cExec: "reject();",
cTooltext: "rejected",
nPos: 1
});

I had it working at one point. Now all I get is

Quote:

myAnnot.transitionToState is not a function
10:App:Exec

This script is saved at the Folder Level of the app.

Not that it matters but I am using Acrobat 9.0 Pro Extended on PCs & Acrobat 7.0 Pro on MACs. This script has only been written and run on one PC.

Any help would be greatly appreciated.

My Product Information:
Acrobat Pro Extended 9.0
lithodora
Registered: Sep 9 2008
Posts: 5
Strange....

var myAnnots = this.selectedAnnots;for ( var i=0; i<myAnnots.length; i++ )myAnnots[i].transitionToState("ReviewStates", "approved");

changing the functions like this did the trick.

Any comments on where I had gone wrong in the first place would still be appreciated.
scottsheck
Registered: May 3 2007
Posts: 138
From looking at your fix, your original code probably would have worked if you used something like:

myAnnot[0].transitionToState("ReviewStates", "accepted");
or
myAnnot[1].transitionToState("ReviewStates", "accepted");

Apparently, you myAnnot field is probably an array, but we can't tell from your example.
lithodora
Registered: Sep 9 2008
Posts: 5
it is possible...

the following may prove the point:
var myAnnot = this.selectedAnnots;console.println(myAnnot);[Markup    1 89dc9d7c-f82a-414f-a1f6-60efc5952117]undefined

if the undefined is part of the variable then it is an array, however:

function approve(){var myAnnot = this.selectedAnnots;myAnnot[0].transitionToState("ReviewStates", "accepted");} function reject(){var myAnnot = this.selectedAnnots;myAnnot[0].transitionToState("ReviewStates", "rejected");} app.addToolButton({cName: "Approved",cExec: "approve();",cTooltext: "approved",nPos: 0});app.addToolButton({cName: "Rejected",cExec: "reject();",cTooltext: "rejected",nPos: 1});

Seems to have no affect.
scottsheck
Registered: May 3 2007
Posts: 138
That is strange. What was the value of myAnnots.length? Does it matter that whether you used the word 'accepted' in one case and 'approved' in another.