Copy a parsed text from Comment field to Summary field

Issue #119 resolved
Shai Dahan created an issue

Hello,

I wounder if this is possible to copy parsed text from a comment within the ticket to a the begging of the summery of the ticket?

Thanks, Shai

Comments (27)

  1. Fidel Castro Armario repo owner

    Hi Shai,

    Yes, it's possible to do it getting the text from issue's last comment (using "Last comment" virtual field), or from the comment entered in current transition's screen (using "Transition's comment" virtual field).

    You should use advanced parsing mode, and functions like "replaceFirst", "replaceAll" and "substring" to extract the text from the comment.

    If you give me details about which text do you need to extract, I will give you exactly the configuration to do it.

  2. Shai Dahan Account Deactivated reporter

    Hello Fidel,

    Thank your prompt response. The scenario goes like that: We have 2 Jira instances which talks to each other by emails which obviously create comment within the specific issue. 1. User create a ticket in Jira1 in a project call "GI" 2. An email is being sent to Jira2 which create a ticket in Jira2 in a project call OCC 3. Ticket is being triage in Jira2 and send an email to Jira1 4. Jira1 handle the email as a comment 5. The comment contain the ticket number of Jira2 ticket (i.e. OCC-6907)

    At this stage we would like to create to add this text (OCC-xxxx) to the beginning of the Summary of Jira1 issue For example if the Summary of Jira1 ticket was "Site is down" change to "[GCI Jira] (OCC-xxxx) Site is down" where xxxx is the issue number of Jira2 Can you help me to achieve this as a post function? We would also need a trigger for this Jira1 to action this post function, meaning Jira1 need to action this only after a comment has been received from Jira2. (it is identified as user in Jira1)

    Currently we are doing it manually

    Many thanks, Shai

  3. Fidel Castro Armario repo owner

    Can you please, give me an example of the comment from JIRA 2 where ticket number appears? I need it to design a way to extract it from the comment.

  4. Shai Dahan Account Deactivated reporter

    The comment appear in Jira1, after an email has been sent from Jira2 Example: ===================================================== GCI OCC added a comment - 04/Apr/15 10:56 AM Gala Coral Interactive OCC New Incident Confirmation - the issue below has been recorded by OCC

    [1]Gala Coral Interactive OCC / [2][3]OCC-6379 [4]GI (GI-13149) - Server error 404

    Issue Type: Incident Created: 03/Apr/15 6:42 PM Reporter: [5]Gala Customer Service Status: Triage Completed Priority: Priority 4 Report Type: Error Message Reporting Departments: [Gala Interactive] Technical Service Affected: Games - Playtech

    Subject: GI (GI-13149) - Server error 404

    (GI-13149) Gala Bingo Priority 3 Incident Notification Server error 404

    Brand: Gala Bingo Priority: !http://galaserviceportal.com/images/icons/priorities/major.png!Priority 3 Incident Description: Username: antoine VF ID: 594246931 Game ID: N/A Game Date & Time: N/A Portal: Mobile Device: Samsung Galaxy S4 C&C: Deleted.

    Please accept my apologies that this P3 doesn't include a specific game and may appear vague. This customer was playing in the early hours of the 3rd April 2015 and was regularly receiving 'Server Error 404'. Please can you give us an explanation why the customer would receive this error from a technical point of view as this customer is getting very upset with us. Customer / Admin Username: antoine

    Date/Time of Customer Session: Friday 03/04/15, 17:34 BST

    Reported by: Jon Custons Created: Friday 03/04/15, 17:41 BST Out of Hours: If the Incident was logged out of hours you must call OUT OF HOURS on-call Telephone number: +350-20010435 ===================================================== We need get the OCC-6379 number and add it in the beginning of the summary for each ticket it's a different number obviously

    Thanks, Shai

  5. Fidel Castro Armario repo owner

    Can you please tell me whether issue key always is between "[2][3]" and "[4]" substrings?

  6. Shai Dahan Account Deactivated reporter

    Yes it always is this format, another example for a comment:

    ================================================

    GCI OCC added a comment - 20/Apr/15 8:31 AM Gala Coral Interactive OCC New Incident Confirmation - the issue below has been recorded by OCC

    [1]Gala Coral Interactive OCC / [2][3]OCC-6958 [4]GI (GI-13629) - Extinction - Broken Game

    Issue Type: Incident Created: 19/Apr/15 11:22 PM Reporter: [5]Gala Customer Service Status: Triage Completed Priority: Priority 3 Report Type: Broken Game Reporting Departments: [CS GALA] Technical Service Affected: Games - Odobo

    Subject: GI (GI-13629) - Extinction - Broken Game

    (GI-13629) Gala Casino Priority 3 Incident Notification Extinction - Broken Game

    Brand: Gala Casino Priority: !http://galaserviceportal.com/images/icons/priorities/major.png!Priority 3 Incident Description: Username - Leopope VF ID - 594384828 Game ID - 3406351620 Date and Time 17/04/15 21:25:22 (BOS Time) Portal or Mobile? Mobile Browser and/or operating system - IPhone 5 App Did the player clear their C&C? Via email was informed previously to do this. Customer informed the game will not play out and they have £504.31

    Customer / Admin Username: leopope

    Date/Time of Customer Session: Sunday 19/04/15, 19:35 BST

    Reported by: Susan Wilson Created: Sunday 19/04/15, 22:21 BST Out of Hours: If the Incident was logged out of hours you must call OUT OF HOURS on-call Telephone number: +350-20010435

    This message was sent by Atlassian JIRA (v6.3.5#6334-sha1:1cd0851)

    This email has been sent from Gala Coral Group Limited ("GCG") or a subsidiary or associated company. GCG is registered in England with company number 07254686. Registered office address: New Castle House, Castle Boulevard, Nottingham, NG7 1FT, United Kingdom; website: www.galacoral.com

    This e-mail message (and any attachments) is confidential and may contain privileged and/or proprietorial information protected by legal rules. It is for use by the intended addressee only. If you believe you are not the intended recipient or that the sender is not authorised to send you the email, please return it to the sender (and please copy it to hq@galacoral.com) and then delete it from your computer. You should not otherwise copy or disclose its contents to anyone.

    Except where this email is sent in the usual course of business, the views expressed are those of the sender and not necessarily ours. We reserve the right to monitor all emails sent to and from our businesses, to protect the businesses and to ensure compliance with internal policies.

    Emails are not secure and cannot be guaranteed to be error-free, as they can be intercepted, amended, lost or destroyed, and may contain viruses; anyone who communicates with us by email is taken to accept these risks. GCG accepts no liability for any loss or damage which may be caused by software viruses.


    [1] https://jira.coral.co.uk/browse/OCC [2] https://jira.coral.co.uk/browse/OCC-6958 [3] https://jira.coral.co.uk/browse/OCC-6958 [4] https://jira.coral.co.uk/browse/OCC-6958 [5] https://jira.coral.co.uk/secure/ViewProfile.jspa?name=mail.galaserviceportal

    ================================================

  7. Shai Dahan Account Deactivated reporter

    In refer to the last example; The original summary of the issue in Jira1 was: "Extinction - Broken Game" and we have manually changed it to: "(OCC-6958) - Extinction - Broken Game"

  8. Fidel Castro Armario repo owner

    You have to use "Copy a parsed text to a field" post-function with the following configuration:

    conf-1.png

    Text to be parsed is: "[GCI Jira] ("+ replaceFirst(replaceFirst(%{00109}, "(?s).*\\[2\\]\\[3\\]\\s*", ""), "(?s)\\s*\\[4\\].*", "") + ") " + %{00000}

    Notice that:

    • %{00000} is field code for "Summary".
    • %{00109} is field code for "Last comment".

    You have to add this post-function in one or more transitions in your workflow. If you don't want to change current status of issue in project GI (Jira1), you can use reflexive transitions (i.e., transitions with same status as origin and destination).

    In order to trigger automatically the transition when issue is commented, you can use JIRA Automation Plugin, which is a free plugin from Atlassian.

    Here I show you some screenshots with the approximate configuration you may need:

    conf-2.png

    conf-3.png

    conf-4.png

  9. Shai Dahan Account Deactivated reporter

    How do add the custom field "Last comment" as is doesn't shows in the "Insert String Value"

    This is a Virtual Field I understand so do I need to add it at all or it's already exist after I've installed the JIRA Workflow Toolbox add-on?

  10. Shai Dahan Account Deactivated reporter

    Cool, found it (it's just that we have so many custom fields and it's not in order alphabetically)

    Now the problem is that it add very long sting as example below: [GCI Jira] (Gala Coral Interactive OCC New Incident Confirmation - the issue below has been recorded by OCC [1]Gala Coral Interactive OCC / [2][3]OCC-7025 I (GI-13650) - Test ticket - PLEASE DO NOT PROCESS Issue Type: Incident Created:"

    also my Automation rule doesn't work for some reason 2015-04-20 16_25_16-Automation - GI Service Portal.png

    Can we also do a condition to check first if the number exist in the Summary as it will create it again every time a comment has been made by the user "occ.coral" ?

  11. Shai Dahan Account Deactivated reporter

    We just need the number of the ticket to be added i.e. "[GCI Jira] (OCC-7025) Test ticket - PLEASE DO NOT PROCESS"

  12. Fidel Castro Armario repo owner

    Sorry, I didn't escaped correctly character "*" in the text to be parsed that copied in the comment. Please, use the following text to be parsed:

    "[GCI Jira] ("+ replaceFirst(replaceFirst(%{00109}, "(?s).*\\[2\\]\\[3\\]\\s*", ""), "(?s)\\s*\\[4\\].*", "") + ") " + %{00000}

  13. Fidel Castro Armario repo owner

    To avoid entering issue key more than once use the following parsed text instead of the one I provided you previously:

    matches(%{00000}, "\\[GCI Jira\\].*") ? %{00000} : "[GCI Jira] ("+ replaceFirst(replaceFirst(%{00109}, "(?s).*\\[2\\]\\[3\\]\\s*", ""), "(?s)\\s*\\[4\\].*", "") + ") " + %{00000}

  14. Fidel Castro Armario repo owner

    Regarding issue on JIRA Automation Plugin try:

    • Removing restrictions: JQL query and user triggering issue event.
    • Test the rule manually by adding a comment with the expected content of a comment automatically introduced by an email.
  15. Shai Dahan Account Deactivated reporter

    Ok, this works well :) However when a new comment it change the Summary as follow:

    "[GCI Jira] (Shai Dahan commented on [1]OCC-7025 [2]Re: GI (GI-13650) - Test ticket - PLEASE DO NOT PROCESS Issue Type: Incident Created: 20/Apr/15 4:05 PM Reporter: [3]Gala Customer Service Assignee: Unassigned Watchers: Gala Custome"

    Can we stop processing after the Summary has been changed once and the number of OCC ticket is already there?

  16. Fidel Castro Armario repo owner

    More than one summary processing will be avoided by using the following parsed text instead:

    matches(%{00000}, "\\[GCI Jira\\].*") ? %{00000} : "[GCI Jira] ("+ replaceFirst(replaceFirst(%{00109}, "(?s).*\\[2\\]\\[3\\]\\s*", ""), "(?s)\\s*\\[4\\].*", "") + ") " + %{00000}

  17. Shai Dahan Account Deactivated reporter

    Great it seems to be working as expected. I've managed to get the Automation rule to work and I've placed condition on the transition that only the user "occ.coral" can activate it, this makes the transition button hidden for all the users. If I'll have any issues I will let you know. World class.... :) you have another fan

  18. Shai Dahan Account Deactivated reporter

    You can expect a great review from me as your support was spot on. I will write a review in the marketplace section for this add-on and its support. Thank you

  19. Fidel Castro Armario repo owner

    I close the issue once resolved. Please, reopen it if you need more support about this issue.

  20. Shai Dahan Account Deactivated reporter

    Hello Fidel,

    We have recently upgraded our Jira to 6.4.2 and the format of the message in the comment is different for example:

    Related issue in the second Jira is OCC-8086 Original value of the description is: Pixies of the Forest - Game not starting Desired of the description should be: [GCI Jira] (OCC-8086) Pixies of the Forest - Game not starting The comment which has been received is: ===================================================================== [cid:jira-generated-image-avatar-paul.talbot-6504faeb-1a10-416c-99a5-f070a05b7081] Gala Coral Interactive OCC New Incident Confirmation - the issue below has been recorded by OCC Gala Coral Interactive OCChttps://jira.coral.co.uk/browse/OCC / [cid:jira-generated-image-static-genericissue-f58c70cd-eed4-4bf8-aaf7-47c96243143c] https://jira.coral.co.uk/browse/OCC-8086 OCC-8086https://jira.coral.co.uk/browse/OCC-8086 GCI (GI-14640) - Pixies of the Forest - Game not startinghttps://jira.coral.co.uk/browse/OCC-8086 Issue Type: [cid:jira-generated-image-static-genericissue-f58c70cd-eed4-4bf8-aaf7-47c96243143c] Incident Created: 18/May/15 2:50 PM Reporter: Gala Customer Servicehttps://jira.coral.co.uk/secure/ViewProfile.jspa?name=gci.jira Status: [cid:jira-generated-image-static-generic-01223566-790a-4ecf-9df2-b53572ae171e] Triage Completed Priority: Priority 3 Report Type: Error Message Reporting Departments: [CS GALA] Technical Service Affected: Games - IGT Subject: GCI (GI-14640) - Pixies of the Forest - Game not starting ===================================================================== The following text parsed in advanced mode will be copied to Summary: matches(%{Summary}, "\[GCI Jira\].") ? %{Summary} : "[GCI Jira] ("+ replaceFirst(replaceFirst(%{Last comment}, "(?s).\[2\]\[3\]\s", ""), "(?s)\s\[4\].*", "") + ") " + %{Summary} ===================================================================== Now the post function doesn't work properly. Could you please help me with the regex in this case?

  21. Fidel Castro Armario repo owner

    Hi Shai,

    Use the following text to be parsed:

    matches(%{00000}, "\\[GCI Jira\\].*") ? %{00000} : "[GCI Jira] (" + replaceFirst(replaceFirst(%{00109}, "(?s).*(?=OCC-\\d+)", ""), "(?s)\\Q" + replaceFirst(replaceFirst(%{00109}, "(?s).*(?=OCC-\\d+)", ""), "^OCC-\\d+", "") + "\\E$", "") + ") " + %{00000}
    

    This solution will work even if the format changes in the future.

    Regards,

    Fidel

  22. Shai Dahan Account Deactivated reporter

    Thanks, this works great and your support always spot on. You can close this ticket now

  23. Log in to comment