Fossil User Forum

Use current ticket as a template for new ticket?
Login

Use current ticket as a template for new ticket?

Use current ticket as a template for new ticket?

(1) By anonymous on 2025-03-01 22:36:36 [source]

Scenario: I have several bugs I want to enter against a "product"; I current use the subsystem field to specify the product.  I am viewing the list of bugs, or a bug for that product.  When I click "New Ticket" I'd like to copy that subsystem value of what I am currently viewing into the new ticket as a default.

Any way to do that without modifying the source code?

(2) By anonymous on 2025-03-06 18:23:51 in reply to 1 [link] [source]

I got part of the way there to a degree that is good enough for me.  It will pre-populate with the subsystem of the most recently modified ticket.

At the very beginning of the top <TH1/> section in the "New Ticket" page HTML I query for the most recently modified ticket:

  if {![info exists preview]} {
    query {SELECT subsystem as myproject FROM ticket ORDER BY tkt_mtime DESC LIMIT 1} {}
  }
  
Then at the very end of the HTML I set the subsystem combobox to the option that matches.

  <script nonce=$<nonce> >
    combobox = document.getElementById("subsystem");
    var i;
    for (i=0; i<combobox.length; i++) {
      if (combobox.options[i].text == '$<myproject>') {
        combobox.selectedIndex = i;
        break;
      }
    }
  </script>

(3) By anonymous on 2025-03-06 20:43:35 in reply to 2 [link] [source]

You might also want to add a where clause to only look at tickets created by the current user.

(4) By Jörgen Kosche (jkosche) on 2025-03-08 16:16:42 in reply to 1 [link] [source]

I started looking into it, because I want something similar. It seems that the tktnew-page already fills the fields with values from another ticket, if you follow the URL: '.../tktnew/<hash of another ticket>'. Which can easily be used to create a copy of the former ticket. I tried it out, simply editing the URL. Only fields that are present in the tktnew-form are reused in the copy.

I am not sure if that is a planned thing or an oversight, but all it needs to get your wished functionality is a submenu in the tktview-page, that links to such a site. Which can be done with the following TH1 on the View Ticket Page:

submenu link "Copy Ticket" /tktnew/$tkt_uuid

(5) By anonymous on 2025-03-08 20:38:04 in reply to 4 [link] [source]

Wow! That works great, even just adding an <a/> link to the ticket view. I like both of these behaviors. Now for a third, I can add a wiki link in a report description and it works also! It's not too bad to just choose or create a reference ticket for that and create the respective tktnew link in the description of each report (I have a similar link to an externally linked git repository too.)

Thank you!

(6) By Jörgen Kosche (jkosche) on 2025-03-09 09:34:01 in reply to 4 [link] [source]

OK, I as I think this is a useful feature I created the branch tktnew-template, where I added this functionality without the need for TH1.

Also this code copies also the private_contact, even if you copy the ticket of someone else. As I think that is not the right way, I changed that to ignore the private_contact of the template.

The default form for new tickets leaves out the fields for priority and subsystem too, which are subsequently not filled. That may be fine for external users, but a user with higher rights has to create a new ticket and then edit it to change these values. So I added a bit of code to show these fields in the new ticket form, but only if you have Write-Tkt rights as well, which allows you to edit these fields later anyways. Note: this changes the default TH1 for new ticket, so it has no effect if you already customized it.

(7) By Stephan Beal (stephan) on 2025-03-09 09:51:04 in reply to 6 [link] [source]

Also this code copies also the private_contact, even if you copy the ticket of someone else. As I think that is not the right way, I changed that to ignore the private_contact of the template.

FWIW, to address your question in /chat about that: IMO that detail shouldn't be copied when cloning a ticket.

The ticket system was one of the very first features added to fossil back in 2007 and it hasn't undergone a lot of change since then. It was, to the best of my recollection, conceptually based on CVSTrac, and it's possible (this is just speculation) that CVSTrac did something similar at the time.

(8) By Jörgen Kosche (jkosche) on 2025-03-09 10:09:31 in reply to 7 [link] [source]

FWIW, to address your question in /chat about that: IMO that detail shouldn't be copied when cloning a ticket.

Yeah, that was my assumption as well, it makes sense if you edit an existing ticket to retain the contact, but if you cloning from a template this field should be filled with the contact of the one creating the ticket (or possibly another address if they report for someone else). That's why I already changed that in the branch.

The ticket system was one of the very first features added to fossil back in 2007 and it hasn't undergone a lot of change since then. It was, to the best of my recollection, conceptually based on CVSTrac, and it's possible (this is just speculation) that CVSTrac did something similar at the time.

I read a bit through the docs of fossil and learned about CVSTrac that way. It is interesting that this inspired Trac. Trac was the first project management system I used and we used at work back in the day. We replaced it with Redmine later, which has a bit more features and feels a bit nicer but does not add major things. And nowadays we use gitlab, which in my opinion does a lot less in regards to project management but instead focuses more on social features. So Redmine is still my preferred reference in regards to project management. But interesting to know that CVSTrac that preceded fossil also inspired Trac.