Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

lfWatch(field, relatedFields, scriptPath[,javaScriptEvents]);

Description

Excerpt
Attach Attaches listeners for the events that you give as parameters in the function.

If you don’t give any event, it this routine 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

ParameterTypeRequiredDescription
fieldStringYesThe field Field to listen .to
relatedFields

Array

String

YesThe dependent Dependent fields required for the given field .(needed only if you get the field's values from the screen like this: argv["field"])
scriptPathStringYesThe script Script source to run when the event is triggered.
javaScriptEventsArrayNoThe events Events to listen to. It's any JavaScript event (check this list for referencesexample)

 

Warning
title"change" event

 When When using the "change" event on a "labels type" field (Fix VersionsfixVersions, Affected Versions, Labels, Components, etc.), the event will never trigger when a label is deleted, but only when labels are added. We have noticed that for these fields the "focusinfocusing" event closely matches the behavior expected for the "change" event.

...

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

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

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

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

Image RemovedImage Added

The first image shows the initial value of the priority for the current issue, the next one shows the value it is changed to, after executing the code from hook.sil.

Image RemovedImage Added 

As we said before, the The values from the relatedFields parameter are accessed as argv[field]. For multiple values fields that can take multiple values (like components or affectedVersions the ), the value returned is in the following format: val1|val2|val3.

...

Info
titleInfo

For more information, see How Live Fields work.

See also

Filter by label (Content by label)
showLabelsfalse
max35
showSpacefalse
sorttitle
cqllabel = "live_fieldslf_routines"