---
title: "lfWatch"
canonical: "https://support.appfire.com/space/PSJ/15480410/lfWatch"
format: markdown
---
> Macro (aura-html)


|  |  |  |  |
| --- | --- | --- | --- |
| **Syntax** | lfWatch(field, relatedFields, scriptPath[,javaScriptEvents]); | **Package** |  |
| **Alias** |  | **Pkg Usage** |  |

## Description

> Macro (excerpt)
> 
> Attaches listeners for the events that you give as parameters in the function.

Attaches listeners for the events that you give as parameters in the function. If you don't give any event, this function attaches listeners to the "change" event which is triggered when the issue is updated. Every time when the event is triggered, the SIL script from **scriptPath** parameter runs. This SIL script receives the values for the **relatedFields** parameter and you can use them as: **argv["field"]**.

## Parameters

| Parameter name | Type | Required | Description |
| --- | --- | --- | --- |
| field | String | Yes | Field to listen to |
| relatedFields | String [] | Yes | Dependent fields required for the given field (needed only if you get the field's values from the screen like this: **argv["field"]**) |
| scriptPath | String | Yes | Script source to run when the event is triggered |
| javaScriptEvents | Array | No | Events to listen to. It's any JavaScript event (check this list for example) |

## Return Type

**None**

## Example

For the **scriptPath** parameter you can either give the relative path (as in the example above), or the absolute path:   
**C:/Program Files/Atlassian/Application Data/JIRA/silprograms/hook.sil**.

```javascript
lfWatch("summary", {"summary", "customfield_13706","components"}, " hook.sil", {"keyup"});
//where field = "summary";relatedFields = {"summary", "customfield_13706","components"};scriptPath = " hook.sil";javaScriptEvents = {"keyup"}
```

Every time when the keyup event is triggered, the hook.sil is executed. When the Summary field contains the word ?important?, the Priority field is set to "Highest" and a message is displayed for the priority fie

```javascript
//hook.sil : 
 if (contains(argv["summary"], "important")) {
    lfSet("priority", "Highest");
    lfShowFieldMessage("priority", "Priority changed", "INFO");
}
```

## See also

> Macro (contentbylabel)