Script API snippets

You can configure TGML graphic components in the Graphics Editor to open a linked target object to a target location. You can do this using the invoke function in a script. When you perform a specific action like PopUp, NewWindow, Link, NewTab, Control on the component, the invoke function is used. You can link TGML graphic components to URLs or TGML files using the LinkFileName attribute.

This topic includes details on the invoke function and attributes.

Script API snippet attributes

The following table lists the invoke function attributes for each snippet type:

NOTE: The invoke function attributes vary depending on the snippet type.

Snippet type Syntax Attributes Description
PopUp

invoke (LinkFileName, "Type = PopUp | ComponentName=" + componentName + " | " + ” | Title=" + title + " | Width=" + width + " | Height=" + height + " | ShowTitleBar =" + showTitleBar + " | CustomExpose=" + customExpose);

Required Attributes for snippet type Pop-Up

Type: Type name displays based on the snippet type selection (Type = PopUp).

ComponentName: Component name is the device name.

Title: The Title attribute maintains and displays the title string when the ShowTitleBar attribute is set to Yes.

Width: Used to set the width of the PopUp.

Height: Used to set the height of the PopUp.

LinkFileName: Used to link a URL or TGML file name.


Optional Attributes for snippet type Pop-Up

ShowTitleBar: Displays the Title Bar in the target pane when set to Yes.

CustomExpose: This attribute contains multi equipment data.

NewWindow

invoke (LinkFileName, "Type = NewWindow | ComponentName=" + componentName + " | Title=" + title + " | Width=" + width + " | Height=" + height + " | CustomExpose=" + customExpose);

Required Attributes for snippet type NewWindow

Type: Type name displays based on the snippet type selection (Type = NewWindow).

ComponentName: Component name is the device name.

Title: The Title attribute maintains and displays the title string when the ShowTitleBar attribute is set to Yes.

Width: Used to set the width of the NewWindow.

Height: Used to set the height of the NewWindow.

LinkFileName: Used to link a URL or TGML file name.


Optional Attributes for snippet type NewWindow

CustomExpose: This attribute contains multi equipment data.

Link

invoke (LinkFileName, "Type = Link | ComponentName=" + componentName + " | CustomExpose=" + customExpose);

Required Attributes for snippet Type Link

Type: Type name displays based on the snippet type selection (Type = Link).

ComponentName: Component name is the device name.

LinkFileName: Used to link a URL or TGML file name.

 

Optional Attributes for snippet type Link

CustomExpose: This attribute contains multi equipment data.

NewTab

invoke (LinkFileName, "Type = NewTab | ComponentName=" + componentName + " | Title=" + title + " | CustomExpose=" + customExpose);

Required Attributes for snippet type NewTab

Type: Type name displays based on the snippet type selection (Type = NewTab).

ComponentName: Component name is the device name.

Title: The Title attribute maintains and displays the title string when the ShowTitleBar attribute is set to Yes.

LinkFileName: Used to link a URL or TGML file name.


Optional Attributes for snippet Type NewTab

CustomExpose: This attribute contains multi equipment data.

Control

tagName = ComponentName + '.' + DataPoint

openBreakerControlDialog({ tagName: tagName, title: componentName, promptForCredentials: true }

Required Attributes for snippet type Control

ComponentName: Component name is the device name.

DataPoint: It is the item name to do the write operation.

User credential Pop-Up

tagName = ComponentName + '.' + DataPoint

writeTags([{DataPointIds: tagName, Value: sessionStorage.getItem("DataPointVal")}], {promptForCredentials: true, title: componentName})

Required Attributes for snippet Type User credential PopUp

ComponentName: Component name is the device name.

DataPoint: It is the item name to do the write operation.

Write Tags

writeTags([{DataPointIds: 'tagName', Value: 1}], {PromptForCredentials: false, Credentials:

{username: 'demo', password: 'demo'}, SuppressMessages: false, Title: 'Write Tag'})

Required Attributes for snippet Type User credential PopUp

Tags: List of tag names and the values to write.

DataPoint: It is the item name to do the write operation.

Optional Attributes for snippet Type Write Tags

PromptForCredentials: Can be set to true or false. If set to true, login credentials popup will display.

Credentials: Allows the engineer to programmatically send a valid username and password.

SuppressMessages: Can be set to true or false. If set to true, all messages will be suppressed.

Title: The Title attribute maintains and displays the title string.

 

Read Tags

readTags(['tagName'], {suppressMessages: false})

Required Attributes for snippet Type User credential PopUp

TagNames: List of tag names the user wants to read values from.

Optional Attributes for snippet Type Read Tags

SuppressMessages: Can be set to true or false. If set to true, all messages will be suppressed.

 

getFwk

const givenPath = getFwk().url.getCdnImageUrl( 'loading.gif' );

This function returns the global fwk object.

Security Audit Log Message

auditLogRequest(message, suppressMessages)

A message to be added to the security audit log, that describes the user action (or any other details that should be conveyed). A second argument can be added for suppressing messages related to the outcome of the log attempt.

Required Attributes for snippet Type Security Audit Log Message

Message: The string message to be logged.

Optional Attributes for snippet Type Security Audit Log Message

suppressMessages: Boolean parameter