Issues with post-function

Issue #130 resolved
Hernan Montes Gil created an issue

Hi there,

I am trying to get values from one issue which uses custom fields as variables, the main issue is when I try to read from a JQL result - this is the configuration: 1. The following text parsed in basic mode will be copied to Ephemeral string 1: %{Application / Area.0} Basically it takes the value of a cascading field (this works fine, in this example let's say it's Camping)

  1. Value of field Ephemeral string 1 in issues returned by JQL query issuekey=TRI-4979 will be copied to field Assignee in current issue. Again, the JQL works fine, I have tested this before, the issue is when I use an Ephemeral value, it doesn't return any result, if I use "Camping" instead of the Ephemeral value it will return the user and set the assignee.

Do you have any suggestions? Thanks.

Comments (28)

  1. Fidel Castro Armario repo owner

    Hi Hernan,

    Ephemeral fields are intended to keep its value only within a transition, i.e., at the end of the transition where they are set they are automatically wiped out.

    Anyway, you can use "Inhibit ephemeral fields auto-clearance" to make its values available for the next transition, but I recommend you to use it only to maintain values of ephemeral fields in sequence of transitions that are executed automatically as a burst, since ephemeral fields are volatile, and they are emptied when JIRA server is reboot.

    I recommend you to use "Copy a parsed text to a field" with the following configuration instead:

    conf-1.png

    Text to be parsed is:

    first(fieldValue(%{99999.0}, filterByFieldValue(getIssuesFromProjects("TRI"), %{00015}, =, "TRI-4979")))
    

    Note that:

    • You have to replace 99999 with field code of "Application / Area" custom field in your JIRA instance.
    • %{00015} is field code for "Issue key".

    Alternatively you can use the following parsed text:

    first(fieldValue(%{99999.0}, filterByPredicate(getIssuesFromProjects("TRI"), ^%{00015} = "TRI-4979")))
    
  2. Hernan Montes Gil Account Deactivated reporter

    Thanks for the fast response, unfortunaly none of the above suggestions worked, the first one didn't update the assignee value and the second returned an error at the transition transition screen. (Index: 0, Size: 0).

  3. Fidel Castro Armario repo owner

    Can you please try the first solution changing "Target field" to virtual field "New comment", in order to see in a issue comment the value that is being "distilled" by the parsed text?

  4. Fidel Castro Armario repo owner

    Second solution had an error. Correct text to be parsed is:

    first(fieldValue(%{99999.0}, filterByPredicate(getIssuesFromProjects("TRI"), ^%{00015} = "TRI-4979")))
    

    Anyway, it won't work, like first solution. I still don't know the reason.

    Can you please try the following text to be parsed with "New comment" as target field?

    "Issues in project TRI: " + count(getIssuesFromProjects("TRI")) + "\n" + "Issues with key TRI-4979: " + count(filterByFieldValue(getIssuesFromProjects("TRI"), %{00015}, =, "TRI-4979")) + "\n" + "Field value: " + first(fieldValue(%{99999}, filterByFieldValue(getIssuesFromProjects("TRI"), %{00015}, =, "TRI-4979")))
    

    Don't forget to replace %{99999} with field code for "Application / Area" custom field in your JIRA instance.

    Once you execute the transition, please tell me the content of the comment created.

  5. Fidel Castro Armario repo owner

    Sorry, I made a mistake in parsed text for debug purpose. Please, use the following parsed text to get the debug comment:

    "Issues in project TRI: " + count(getIssuesFromProjects("TRI")) + "\n" + "Issues with key TRI-4979: " + count(filterByFieldValue(getIssuesFromProjects("TRI"), %{00015}, =, "TRI-4979")) + "\n" + "Field value: " + first(fieldValue(%{99999}, filterByFieldValue(getIssuesFromProjects("TRI"), %{00015}, =, "TRI-4979")))
    
  6. Hernan Montes Gil Account Deactivated reporter

    I tried the last text and returned the index: 0 error, I added the .0 index which did not had before and returned this

    Issues in project TRI: 1324 Issues with key TRI-4979: 1 Field value:

  7. Hernan Montes Gil Account Deactivated reporter

    last used: "Issues in project TRI: " + count(getIssuesFromProjects("TRI")) + "\n" + "Issues with key TRI-4979: " + count(filterByFieldValue(getIssuesFromProjects("TRI"), %{Issue key}, =, "TRI-4979")) + "\n" + "Field value: " + first(fieldValue(%{Application / Area.0}, filterByFieldValue(getIssuesFromProjects("TRI"), %{Issue key}, =, "TRI-4979")))

  8. Fidel Castro Armario repo owner

    The problem is that "Application / Area" is not set in issue TRI-4979. I supposed that that custom field will always be set.

    Please tell me:

    • Is it posible that "Application / Area" will not be set?
    • In case last question is answered affirmatively, do you want current issue to become unassigned?
  9. Hernan Montes Gil Account Deactivated reporter
    • I guess that I failed to mention how I supposed this would work, When I tried to parse the text in application / area it returns the text with the name of the custom field I want the value to return - example, application / area = DynamicsCRM / NA, I put the parsed text in an ephemeral text, in this case ephemeral text = DynamicsCRM, then I will do a JQL search where I want TRI-4979 to be searched and the custom field which holds the value I want is called DynamicsCRM which is what ephemeral text contains, if this isn't possible can you suggest a workaround, for testing purposes first I made sure ephemeral actually contained something so I added a post-script which updates a custom text field in the current issue with the contents of ephemeral and worked, the custom field was set to DynamicsCRM but when I used the JQL post-function it didn't returned nothing.
  10. Fidel Castro Armario repo owner

    Three questions:

    1. Is it possible that field "Application / Area" is unset in for issue with key "TRI-4979"?
    2. Are you always working with project "TRI" and issue "TRI-4979" or may you need to work with different projects and issues?
    3. In case project or issue may be different, how will you determine which project and issue are you working with?
  11. Hernan Montes Gil Account Deactivated reporter
    1. Field is not being used in TRI-4979
    2. Always working with that issue and project
    3. N/A
  12. Hernan Montes Gil Account Deactivated reporter
    • Fields used in TRI-4979 are named after Application / Area options not the actual field, one these options is DynamicsCRM so in TRI-4979 the custom field is called DynamicsCRM and the value I want to retrieve is the user since it is an user custom field.
  13. Fidel Castro Armario repo owner

    One last question: Will "Application / Area" always be set in current issue?

  14. Hernan Montes Gil Account Deactivated reporter

    further info - this works: Value of field Docusign.com - eCommerce and Support in issues returned by JQL query issuekey = tritest-21 will be copied to field Assignee in current issue. This does not work: Value of field Ephemeral String 1 in issues returned by JQL query issuekey = tritest-21 will be copied to field Assignee in current issue.
    So I need to reference the field directly instead of using an ephemeral string, one question can a function retrieve the custom field code depending on application / area selection and add the code to ephemeral string 1 so instead of the content of ephemeral is the name of the custom field it would be the custom field code number?

  15. Fidel Castro Armario repo owner

    It doesn't work as you expect since what the post-function is doing is to read field "Ephemeral string 1" of issue tritest-21.

    What you seems to be expecting so to read the field of issue tritest-21 whose name is stored in current issue's Ephemeral string 1 field. Isn't it?

    Another question: Approximately, how many possible values do you have in "Application / Area" custom field?

  16. Hernan Montes Gil Account Deactivated reporter

    I see, so there's no way of telling the post-function to actually read the content of ephemeral string instead of literally reading "Ephemeral String 1"

  17. Fidel Castro Armario repo owner

    Currently there is a way, but is very cumbersome for 15 options. Anyway, doing certain improvement to post-function "Set field as a function of other fields" it will be possible to implement it in a practical way.

    If you give me a week or so, I will provide a beta version with the needed improvement, and will explain you how to implement what you intend to do.

  18. Hernan Montes Gil Account Deactivated reporter

    How's it going Fidel, do you have any updates on this? Thanks.

  19. Fidel Castro Armario repo owner

    Hi Hernan, I will provide the beta version and the description of the solution tomorrow morning.

  20. Fidel Castro Armario repo owner

    Hi Hernan,

    I have made available version 2.1.32_beta_10 which implements an improvement in "Set field as a function of other fields" which consists in optional prefixes for setting rules, in order to modulate their behavior.

    Current version only provides support for prefix "a", which enforces the value part of the setting rule where its inserted to be treated as advanced parsing text expression.

    Using this version of the plugin you can implement your requirements using "Set field as a function of other fields" with the following configuration:

    conf-1.png

    Setting rules are:

    a[%{99999.0} = "Field A"]first(fieldValue(%{aaaaa}, filterByFieldValue(getIssuesFromProjects("TRI"), %{00015}, =, "TRI-4979")))
    a[%{99999.0} = "Field B"]first(fieldValue(%{bbbbb}, filterByFieldValue(getIssuesFromProjects("TRI"), %{00015}, =, "TRI-4979")))
    a[%{99999.0} = "Field C"]first(fieldValue(%{ccccc}, filterByFieldValue(getIssuesFromProjects("TRI"), %{00015}, =, "TRI-4979")))
    a[%{99999.0} = "Field D"]first(fieldValue(%{ddddd}, filterByFieldValue(getIssuesFromProjects("TRI"), %{00015}, =, "TRI-4979")))
    

    Where:

    • %{00015} is field code for "Issue key".
    • 99999 is numeric part of field code for "Application / Area" custom field.
    • aaaaa is numeric part of field code for "Field A".
    • bbbbb is fnumeric part of ield code for "Field B".
    • ccccc is numeric part of field code for "Field C", and so on.

    In your case you will have to use 15 setting rules, one for each option available in first level of field "Application / Area".

  21. Hernan Montes Gil Account Deactivated reporter

    Thanks for the changes, I'm a little confused right now, so the field to be checked for is no longer applicable? (In your screenshot is summary), in the case of %{aaaaa}, are these the custom fields I created in TRI-4979 which are the same name as the application / area options?

  22. Fidel Castro Armario repo owner

    Value of parameter "Field to be checked..." doesn't matter, since we are only using type 2 setting rules.

    %{aaaaa} is the field code for custom field set in TRI-4979, and same as options in "Application / Area" custom field.

    Indeed, it is not needed that both, the name of the custom fields and the field options to be the same, since each setting rule connects a pair custom field - field option.

  23. Log in to comment