[rt-users] Pre-Populate Description

Matt Zagrabelny mzagrabe at d.umn.edu
Tue Aug 4 16:15:08 EDT 2015


On Tue, Aug 4, 2015 at 2:57 PM, Joseph D. Wagner <joe at josephdwagner.info> wrote:
> I would like to pre-populate the description of a new ticket. For example,
> if I filed a bug on Red Hat's Bugzilla, a new bug description already
> contains the text:
>
> Component:
> Version:
> Problem:
> Expected Results:
> Actual Results:
> Additional Info:
>
> A feature like this would be very helpful to guiding users with what data
> they should enter. Can this be done in RT? If so, how?

You can do this in a variety of ways. Each with their own amount of
work and with their own caveats for use-case. There are probably more
ways that I am not aware of, too.

Use Articles. This is pretty easy, but to my knowledge, the users will
have to select the article from a drop down to get the text into your
content box.

Use QuickCalls:
http://search.cpan.org/dist/RT-Extension-QuickCalls/lib/RT/Extension/QuickCalls.pm
When the user selects an entry from the quick call list, the resulting
ticket content can be populated with the article.

Here is a config snippet:

Plugin('RT::Extension::QuickCalls');

Set(
    $QuickCalls,
    [
        {
            Name                             => 'Elevated Rights',
            Queue                            => 'End User Support',
            Status                           => 'resolved',
            SetOwnerToCurrentUser            => 1,
            'Articles-Include-Article-Named' => 'Elevated Access Rights',
            CommentContent                   => q{},
        },
    ]
);

Use a callback to add the text for the given queue. Forgive me the
pasting of code in an email. You'll get the concept.

$ cat html/Callbacks/RT-Site-UMN-Duluth-EducationalTechnology/Elements/MessageBox/Default
<%perl>
if (
    (grep /^Create\.html$/, map({$_->name} $m->callers))
        # ensure we are at Create.html
    &&
        # AND
    (
        ! defined $ARGS{Name}
        # Name parameter is not defined
        ||
        # OR
        $ARGS{Name} ne 'CommentContent'
        # Name is not CommentContent (CommentOnCreate)
    )
    &&
        # AND
    (
        # we are creating in the Educational Technology queue
        (
            defined $parent_args->{Queue}
        # definededness check
            &&
        # AND
            (
        # Queue matches a number and is Educational Technology id
                (
        # or queue does not match a number and is 'Educational
Technology'
                    $parent_args->{Queue} =~ /^\d+$/
                    &&
                    $parent_args->{Queue} ==
$educational_technology_queue_id  # "Normal" ticket creation
                )
                ||
                (
                    $parent_args->{Queue} !~ /^\d+$/
                    &&
                    $parent_args->{Queue} eq 'Educational Technology'
        # Quick Create
                )
            )
        )
        ||
        # OR
        (
            defined $parent_args->{Problem}
        # definededness check
            &&
        # AND
            $parent_args->{Problem} =~
/^$educational_technology_queue_id-/    # CreateByProblemType
        )
    )
) {
</%perl>
<% $content | n %>
<%perl>
}
</%perl>
<%init>
my $parent_args = $m->request_args;

my $educational_technology_queue = new RT::Queue($session{CurrentUser});
$educational_technology_queue->Load('Educational Technology') || return;
my $educational_technology_queue_id = $educational_technology_queue->id;

my $content = <<__END_OF_CONTENT__;
What is the name of the course, its number and section (e.g., Writing
Studies 1120, section 1)?


What is the specific issue (e.g., students are reporting the quiz in
week 13 is not available)?
__END_OF_CONTENT__

$content = $m->interp->apply_escapes(
    $content,
    'h',
);

if (RT->Config->Get('MessageBoxRichText',  $session{CurrentUser})) {
    $content = "<pre>$content</pre>";
}
</%init>

-m



More information about the rt-users mailing list