Populate a comments box based on a selection from a drop down box?

Issue #414 resolved
Scott McDonald created an issue

Is there way to populate a comments box based on a selection from a drop down box?

For example, in a drop down field we have four options to choose from: A, B, C, D. If the user selects the option "A', a certain set of information will be added to comments (or a different field). If option 'B' is selected, a different set of information is automatically added to comments (or a different field).

In other words, I would like a comment to be created in current issue based on the value of a selectable field.

Comments (17)

  1. Fidel Castro Armario repo owner

    Hi Scott,

    Yes, you can do it using "Add a comment" post-function. You should insert in a transition as many instances of this post-function as different comments you have.

    Insert a boolean expression in parameter Conditional execution of each post-function, in order to execute only the one corresponding to the current value of the drop down field. The boolean expressions to use are like this one:

    %{nnnnn} = "certain_value"
    

    replacing nnnnn with the field code of drop down field, and certain_value with the desired value in each post-function.

  2. Scott McDonald reporter

    nothing is being inserted into the field I specify. Here's my exact business use case.

    We have a field with an ID of 14005 named Standard Equipment. In that fields dropdown there are a number of values to choose from like Accounting, Finance, etc. I would like added to the comments field information for the specific value they choose. For Example, if the user selects Accounting from the dropdown (Standard Equipment field), I would like the comments field to be populated with: Monitor, Keyboard, calculator. Then if they choose the Finance option, the comments field would be populated with: Software, desk, cables.

    Is that possible?

  3. Fidel Castro Armario repo owner

    The solution I gave you was for creating a new issue comment. Now, I think that what you want to do is to set a custom field called "Comments". I have a pair of questions:

    1. Which type is custom field Comments?
    2. Do you want to overwrite the content of Comments custom field, or do you prefer to add new values keeping current content of the field?
  4. Scott McDonald reporter
    1. Comments is the standard JIRA comments field. I haven't created anything custom when it comes to Comments.
    2. No overwriting
  5. Fidel Castro Armario repo owner

    Then, it should be working. Can you please attach a screenshot of the post-function's tab of the transition where you are trying to create the comments? I would like to see all the post-functions you are executing.

    Thanks

  6. Fidel Castro Armario repo owner

    If you leave parameter Conditional execution empty, the post-function will be executed unconditionally. You can try leaving it empty, and the post-function will be executed.

    Can you please attach a screenshot of the post-function's tab of the transition where you are trying to create the comments?

  7. Scott McDonald reporter

    That is from the transition i'm attempting to add the comments. It's on the Open transition.

    Screen Shot 2016-09-23 at 12.51.50 PM.png

  8. Fidel Castro Armario repo owner

    This post-function is "Copy a parsed text to a field", but I told you to use "Add a comment".

    Anyway, you can do it also using "Copy a parsed text to a field". I explain you how:

    1. Select New comment in "Target field" parameter.
    2. Input the text content of your comment into parameter "Text to be parsed and copied to target field".

    I assume that %{14005} is the field code of the drop down custom field you mentioned in the description of the issue. Isn't it?

  9. Scott McDonald reporter

    I did find Add a comment and that seems to work! I was able to get the info added to comments. Yes, 14005 is the field code for Standard Equipment. This is the field with the dropdown values to choose from.

    Question: Different information needs to be added to the comments per the selection they choose (A, B, C or D). What will that look like in the "Text to be parsed and then copied to target field"?

  10. Fidel Castro Armario repo owner

    Yes, that is a possibility, but if the text content of the comment is a short (a single line), then I recommend to use "Set a field as a function of other fields" with a configuration similar to this:

    Set a field as a function of other fields configuration.png

    • Field to be checked for matching...: Standard Equipment
    • Target field: New comment

    Settings rules in this example are:

    (Accounting)Monitor, Keyboard, Calculator
    (Maintenance)Screwdriver, Pliers
    (Chef)Spoon, Pan, Knife
    

    As you can see, there are many ways to the same thing.

  11. Scott McDonald reporter

    I can't see the image you pasted but I applied what you have in the example and it doesn't work. Here's a screenshot of what my logic looks like.

    Screen Shot 2016-09-23 at 1.52.10 PM.png

  12. Fidel Castro Armario repo owner

    It seems that there is some kind of problem attachments in Bitbucket. I have edited my previous post and explained the values of parameters "Field to be checked for matching..." and "Target field". Please, revise your configuration.

  13. Scott McDonald reporter

    That worked. Is there a way to have each value appear on it's own separate line in the comments. For example, if value D under Standard Equipment has the values of pencil, paper, calculator, notebook, can I have those each on their own separate line...

    Pencil Paper Calculator Notebook

  14. Fidel Castro Armario repo owner

    Use the following setting rules instead:

    a(Accounting)"Monitor\nKeyboard\nCalculator"
    a(Maintenance)"Screwdriver\nPliers"
    a(Chef)"Spoon\nPan\nKnife"
    

    Don't forget the 'a' prefix, which activates the advanced parsing mode for the value part of the rule.

  15. Scott McDonald reporter

    That works. The only change I had to make was one slash instead of two.

    Logic: a(Accounting)"Macbook\nPC\nTablet" Results:

    Macbook PC Tablet

  16. Fidel Castro Armario repo owner

    You are right Scott: only one \ is needed. I have edited my previous post and corrected it.

  17. Log in to comment