Adding Toolbar Labels with JavaScriptJavaScript can be used to create a Toolbar Label at any time in a Workflow, and allows more flexibility to include dynamic parameters or control when a Label is created.
How ToInside any JavaScript-manipulating Field (Calculate, JavaScript, JavaScript - Button), use the Script.Labels.Add() function.
Simple Syntax
The simple syntax requires a list of parameters:
Script.Labels.Add(text, toolbar, row, name);
Example:
Alternate Syntax
Since many of the arguments for the above syntax are optional, there is an alternate syntax where a JavaScript object is passed instead. This means that only the desired optional parameters need to be passed:
Any optional parameters that are omitted will use their default value, as stated in the above table. As this is a JavaScript object, the order in which the parameters are listed in this alternate syntax doesn't matter, as long as the key:value pairs are preserved.
NotesAs multiple duplicate Toolbar Labels can be created if a name isn't specified, it is advised that caution is used if this function is invoked in a Calculate Field, due to the way that Calculate Fields will run every time a field is selected or action is taken.
Both Fields and Variables can be used in the parameters to allow dynamic content. Be aware that to use a combination of dynamic and static text requires treating the Fields or Variables as string fragments to be assembled.
As the function returns the name of the created Label, it's possible to close the Label later even without a name defined:
var myLabel = Script.Label.Add("myText");
if (myCondition == "yes") { Script.Label.Remove(myLabel); }
|