Slack notification when a task is added/moved to a specific kanban column
Hello, I want to receive notification in Slack when a task is added/moved to a specific kanban column, I have tried to use workflow constructor but constructor is not suitable for that, if i am understanding correctly, using javascript is the only way, are there any code examples of working with specific kanban column and slack notifications?
Please sign in to leave a comment.
Hi!
You can build a custom Slack integration to accommodate your case. A column change is just a state value change, so you can create a workflow (a custom script) that would send a request to Slack when an issue's value is changed. You can see a detailed guide on building a custom Slack integration here: https://www.jetbrains.com/help/youtrack/devportal/Slack-Integration-HTML.html
Also, if you are not familiar with the workflow functionality, make sure to check our tutorial.
Hi, i have tried to add a new line of code to slack js workflow, i've added this line: (i found it on this forum)
so, now my code look like this
However, now the whole kanban project doesnt work, what i am doing wrong?
Thanks for your reply.
Do you mean you get a workflow error when you try to change something in the project's issues? If so, check the workflow's console that will show a related error. Feel free to share the error if you don't know what it means.
Generally, if the workflow itself doesn't work and you don't know why, then you can add console.log() for related variables to debug your code. If you use an IDE, then you can use advanced debugging tools via remote debugging.
Hi, i have checked console and found this error:
I am not sure if this line of code is the right one in my case (i just want notification when an issue is created/moved to a specific column)
The error should also point you to the exact line of the code that triggers this error. Please check it.
In the tutorial I shared, there's an example of a rule when a specific field value changes (the value is the same thing as the column in your case), so you can use it as a base: https://www.jetbrains.com/help/youtrack/devportal/Quick-Start-Guide-Workflows-JS.html#write-first-rule-quick-start
In your current rule that you sent, the column (value) is not checked at all.
Hi, I have used your example of a rule, and now my column value is being checked, however now i get notification even if i drag a card to any column (i want notifications only when a card is dragged to the column ''Doing')
Hello,
Thank you for sharing your code.
I inspected it and saw that you use the isChanged() method in the `guard` section. This method accepts one parameter and checks if the field is changed in general. If you wish to check the new value of this field, I recommend you use the becomes() method. According to it, the `guard` section will look as follows:
It worked, thanks a lot for the help!
You are welcome!