Writing Listeners. Examples

 

A very simple issue listener

Open the SIL Manager and save the following script as “example1_listener.sil

//simply adds a comment addComment(key, currentUser(), "Your description is " + length(description) + " characters long");

 

Install the script by going to Power Apps Config → Advanced → Listeners, use the Issue Created event

In the above Image, I have disabled all the other listeners to concentrate only on the actions added by the example script.

 

Go in your test project and test it. Each time an issue is created, that comment should appear in the issue after some time:

 

An issue listener on updates

Let’s create another listener, this time watching the updates on the fields of the issue. We will filter on the TEST project as well so we can really show the true power behind the listener.

Using the SIL Manager write the following script:

//check if the field of interest was changed if(project == "TEST" && isIssueFieldChanged("description")) { //get the change and play ! JFieldChange change = getEventIssueFieldChange("description"); addComment(key, currentUser(), "Field " + change.field + " ( changed by " + change.user + "), old size was " + length(change.oldVal) + " chars, now is " + length(change.newVal) + " chars"); } //The following may be used to deal with multiple changes: //JFieldChange [] arr = getEventIssueChanges(); //if you want to intercept multiple changes, you may get them and process accordingly

 

Save it under the name “example2_listener.sil“:

Again, install the script by going to Power Apps Config → Advanced → Listeners, but this time choose the event “Issue Updated

 

Let’s edit the description of the previous created issue:

 

 

Peacock