On this Page

    Custom Design Script Menu

    Users can create custom options in the Design Script Editor by placing a DesignScriptMenu.json file in the DocOrigin Overrides ($O) folder. The example below shows some simple, real JavaScript options along with a few "Sample Only" entries. In this example, options will display:

    • directly in the top menu
    • child menu with seven real JavaScript Samples
    • and a second child menu level with 3 fake samples
    $O/DesignScriptMenu.json
    {
    	"Direct Snippet at Top of Script Menu" : "insert script goes here",
    	"Custom Menu with List of Snippets" :
    	{		
    		"Sum Example" : "this._value = _document.sum('INSERT_FIELD_NAME')",
    		"Hide Parent if this is Blank" : "if (this._value == '') this._parent._presence = 'none'",
    		"Log String with Raw Value" : "_logf('My message is = %s',this._raw)",
    		"Data-driver Placeholder" : "this.setTag('placeholder', _data.insertQualifiedFieldName._value + '.pdf')",
    		"Show Me on Face (Odd Page) - Must be On Pagination Completed" : "if (this._pageNumber % 2 == 0) this._presence = 'none'",
    		"Remove Extra Trailing CR" : "this._value =  this._value.replace('\n', '')",
    		"Child Custom Menu with Snippet List" :
    		{
    			"Sample Snippet 1" : "xxx",
    			"Sample Snippet 2" : "yyy",
    			"Sample Snippet 3" : "zzz"
    		}
    	}
    }

    As you can see in the screenshot below, two new top-level options are shown, Direct Snippet at Top of Script Menu and Custom Menu with List of Snippets.

    • You can create a set of options with a parent menu by enclosing it in curly brackets.
    • The name shown to the user is on the left side of the colon (:) enclosed in double-quotes such as "Sum Example"
    • The inserted script is on the right side of the colon (:)  enclosed in double-quotes such as "this._value = _document.sum('INSERT_FIELD_NAME')"
      • If your script contains quotes, single quotes must be used
      • You can include placeholders to help the user such as INSERT_FIELD_NAME
    • Each option in a list must be divided by a comma
    • Try it! Create a file called DesignScriptMenu.json and place it in your $O/Overrides folder and paste the content above.