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

Create a Bookmark containing Action/Javascript from the Console

Community Expert ,
Jul 31, 2024 Jul 31, 2024

Copy link to clipboard

Copied

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!

TOPICS
JavaScript

Views

349

Translate

Translate

Report

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
2 ACCEPTED SOLUTIONS
Community Expert ,
Jul 31, 2024 Jul 31, 2024

Copy link to clipboard

Copied

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

View solution in original post

Votes

Translate

Translate

Report

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 Expert ,
Jul 31, 2024 Jul 31, 2024

Copy link to clipboard

Copied

'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'+
    '}'

View solution in original post

Votes

Translate

Translate

Report

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 Expert ,
Jul 31, 2024 Jul 31, 2024

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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 Expert ,
Jul 31, 2024 Jul 31, 2024

Copy link to clipboard

Copied

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();
    }

 

Votes

Translate

Translate

Report

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 Expert ,
Jul 31, 2024 Jul 31, 2024

Copy link to clipboard

Copied

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'

Votes

Translate

Translate

Report

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 Expert ,
Jul 31, 2024 Jul 31, 2024

Copy link to clipboard

Copied

'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'+
    '}'

Votes

Translate

Translate

Report

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 Expert ,
Jul 31, 2024 Jul 31, 2024

Copy link to clipboard

Copied

Thanks! I see I can use \n instead of \r.

Votes

Translate

Translate

Report

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 Expert ,
Jul 31, 2024 Jul 31, 2024

Copy link to clipboard

Copied

LATEST

Yes,

\n=new line

\r= carriage return

Votes

Translate

Translate

Report

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