Adding watchers to issues based on projects

Issue #824 new
Modha Khammammettu
created an issue

I use your plugin workflow toolbox and need some help on a particular requirement.

We would like to add watchers whenever a new issue is created for Bug issue type. But the watchers differ based on the project.

Ex: if a bug issue is created for projecta than usera, userb should be added as a watcher. If a bug is created for project then userx and usery should be added as watcher.

Can you please give me an idea or code snippet.

Jira version 7.1.9

Thanks Kumar

Comments (6)

  1. Fidel Castro Armario repo owner

    Hi @Modha Khammammettu,

    My recommendation is to create a project role for that specific purpose (let's suppose 'Bug Watcher'), and then add "Copy a parsed text to a field" post-function to transition "Create Issue" with the following configuration:

    • Target field: New watchers
    • Parsing mode: advanced
    • Text to be parsed: toString(usersInRole("Bug Watcher"))

    Be careful to add your post-function just after post-function "Creates the issue originally".

    Now, you simply have to assign project role Bug Watcher to the corresponding user in each project.

  2. Modha Khammammettu reporter

    Hi Is it possible to put a component and or value of custom field into picture as well

    Projecta + componentb+ custom field value a = users added as whatever Project a + component b + custom field value a = userb added as watcher

    Please let me know

  3. Fidel Castro Armario repo owner

    Hi @Modha Khammammettu,

    In this case you should use a totally different approach: use post-function "Set a field as a function of other fields" with a configuration like this one:

    Captura de pantalla 2017-10-05 a las 13.52.56.png

    Setting rules in the example are:

    [%{00018} = "CRM" AND %{00094} ~ "Component A" AND %{00017} = "Critical"]user_a
    [%{00018} = "CRM" AND %{00094} ~ "Component B" AND %{00017} = "High"]user_b
    [%{00018} = "CRM"]user_c
    [%{00018} = "HPR" AND %{00094} ~ "Component A"]user_k
    [%{00018} = "HPR" AND (%{00094} ~ "Component B" OR %{00094} ~ "Component C")]user_t
    [%{00018} = "HPR"]user_w
    

    where %{00018} is field code for Project key, %{00094} is field code for Components and %{00017} is field code for Priority.

    You should have in mind that you can write only one setting rule per line, and that setting rules are evaluated in order. I expect that you will be able to understand how to adapt the example to your specific requirements.

    Please, ask any question or doubt you have about the proposed solution.

  4. Modha Khammammettu reporter

    It works great. Thank you.

    I am using like this:

    [%{00018} = "GFX" AND %{00094} ~ "XXX" AND %{00014} = "Bug" AND %{10205} = "aag"]h.kim

    2 questions:

    1. If I have to put 2 users as watchers instead of 1 for the same condition, can I do it. Something like

    [%{00018} = "GFX" AND %{00094} ~ "XXX" AND %{00014} = "Bug" AND %{10205} = "aag"]h.kim, j.tim

    1. I have something like this:

    [%{00018} = "GFX" AND %{00094} ~ "XXX" AND %{00014} = "Bug" AND %{10205} = "asz"]aj.k

    [%{00018} = "GFX" AND %{00094} ~ "XXX" AND %{00014} = "Bug" AND %{10205} = "rop"]aj.k

    [%{00018} = "GFX" AND %{00094} ~ "XXX" AND %{00014} = "Bug" AND %{10205} = "com"]aj.k

    [%{00018} = "GFX" AND %{00094} ~ "XXX" AND %{00014} = "Bug" AND %{10205} = "tbk"]aj.k

    Here everything is same except my custom field value, is there a way to compress it into single line ex:

    %{10205} in "asz,rop,com,tbk"

    I tried to go through your examples but did not find a solution.

    Thanks Kumar

  5. Fidel Castro Armario repo owner

    Hi @Modha Khammammettu,

    I answer your 2 questions:

    1. Yes, in order to add more than one watcher in the same setting rule, you can write a comma separated list of user names.

    2. You can use a setting rule like this one:

    [%{00018} = "GFX" AND %{00094} ~ "XXX" AND %{00014} = "Bug" AND %{10205} in ["aag", "asz", "rop", "com", "tbk"]]aj.k
    

    You should also check parameter "Evaluate all setting rules, not stopping at first match.".

  6. Log in to comment