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!
Copy link to clipboard
Copied
var root = this.bookmarkRoot;
var bookmark1 = root.createChild("Form Highlight On/Off",
'app.runtimeHighlight = !app.runtimeHighlight;')
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'+
'}'
Copy link to clipboard
Copied
var root = this.bookmarkRoot;
var bookmark1 = root.createChild("Form Highlight On/Off",
'app.runtimeHighlight = !app.runtimeHighlight;')
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();
}
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'
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'+
'}'
Copy link to clipboard
Copied
Thanks! I see I can use \n instead of \r.
Copy link to clipboard
Copied
Yes,
\n=new line
\r= carriage return