Skip to main content
jctremblay
Community Expert
Community Expert
July 31, 2024
Answered

Create a Bookmark containing Action/Javascript from the Console

  • July 31, 2024
  • 1 reply
  • 1170 views

I have this javascript that I run from the Console to create a bookmark containing an Javascript Action.

 

var root = this.bookmarkRoot;
var bookmark1 = root.createChild("Form Highlight On/Off", function() {
    app.runtimeHighlight = !app.runtimeHighlight;
});

 


The bookmark is created but, with this as javascript:

 

function() {
    app.runtimeHighlight = !app.runtimeHighlight;
}

 

I can’t figure out to not create a function, like so:

 

app.runtimeHighlight = !app.runtimeHighlight;

 

or to create a named one:

 

function bm() {
    app.runtimeHighlight = !app.runtimeHighlight;
}
bm();

 


How?

Thanks!

This topic has been closed for replies.
Correct answer PDF Automation Station
'if (app.alert({\r'+
        'cMsg: "Do you really want to clear the entire Form?",\r'+
        'cTitle: "Reset Form",\r'+
        'nIcon: 2,\r'+
        'nType: 2\r'+
    '}) == 4) {\r'+
        'this.resetForm();\r'+
    '}'

1 reply

PDF Automation Station
Community Expert
Community Expert
July 31, 2024
var root = this.bookmarkRoot;
var bookmark1 = root.createChild("Form Highlight On/Off", 
    'app.runtimeHighlight = !app.runtimeHighlight;')
jctremblay
Community Expert
Community Expert
July 31, 2024

Thanks! I was close... 🙂

Now how can you add multiples lines code?
So instead of one line like:

var bookmark2 = root.createChild("Reset Form Fields", 'if (app.alert({cMsg: "Do you really want to clear the entire Form?",cTitle: "Reset Forms",nIcon: 2,nType: 2}) == 4) {this.resetForm();}')

It’s more lisible like so in the bookmark:

    if (app.alert({
        cMsg: "Do you really want to clear the entire Form?",
        cTitle: "Reset Form",
        nIcon: 2,
        nType: 2
    }) == 4) {
        this.resetForm();
    }

 

PDF Automation Station
Community Expert
Community Expert
July 31, 2024

Split the code between the '  ' and use return characters like this:

'line 1 blah blah blah\r'+

'line 2 kjkjkjkkjkj\r'+

'line 3 abcdefgh\r'