Power Scripts : How to add auto comment using listeners
This article helps to add automatic comments every time a new ticket is raised in the project.
First of all, the following SIL script has to be created:
// gather all required data here
string sum1 = description;
string dat = currentDate();
string rep = getUser(key.reporter)[2];
string title = summary;
// add comment
addComment(key,currentUser(), " Hello " +rep+ " you have raised ticket on : " +dat+ " and description of your ticket is : " +sum1+ " Someone from our team will contact you shortly!");
// then save it to a file to check all raised tickets
printInFile("Raised_tickets_2024.txt", " Ticket number : " + key + " Reported by : "+ rep + " Raised on : "+dat+ " Title : " +title);
In this example, I’m saving the script as ticket_summary.sil
This script gathers all required data when the ticket has been created, like description, current date, and ticket summary. Then, it adds a comment and saves all data in a single text file for future data insights if required, as this script will be triggered without our attention!
Now, after creating the script, you have to go to > Power Apps Config and click Add listener. In this case, the script will be triggered whenever the “Issue Created” event occurs, in other words, when an issue will be created. Also, you have to specify the project where you want this script to work and locate the script path.
After that, whenever an issue has been created you should see this comment :
Also, all tickets will be available to see in one file under Raised_tickets_2024.txt