Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
best-practical
rt
Commits
8c84e38b
Commit
8c84e38b
authored
Aug 27, 2014
by
Alex Vandiver
Browse files
Merge branch '4.2/loadable-object-for-attribute-initialdata' into 4.2-trunk
parents
15a3df1b
e7290b0e
Changes
3
Hide whitespace changes
Inline
Side-by-side
docs/initialdata.pod
View file @
8c84e38b
...
...
@@ -427,8 +427,33 @@ L<RT::Template/Create> for the fields you can use.
An array of L<RT::Attribute>s to create. You likely don't need to mess with
this. If you do, know that the key C<Object> is expected to be an
L<RT::Record> object on which to call C<AddAttribute>. If you don't provide
C<Object> or it's undefined, C<< RT->System >> will be used.
L<RT::Record> object or a subroutine reference that returns an object on which
to call C<AddAttribute>. If you don't provide C<Object> or it's undefined,
C<< RT->System >> will be used.
Here is an example of using a subroutine reference as a value for Object:
@Attributes = ({
Name => 'SavedSearch',
Description => 'New Tickets in SomeQueue',
Object => sub {
my $GroupName = 'SomeQueue Group';
my $group = RT::Group->new( RT->SystemUser );
my( $ret, $msg ) = $group->LoadUserDefinedGroup( $GroupName );
die $msg unless $ret;
return $group;
},
Content => {
Format => <<' END_OF_FORMAT',
....
END_OF_FORMAT
Query => "Status = 'new' AND Queue = 'SomeQueue'",
OrderBy => 'id',
Order => 'DESC'
},
});
=head2 C<@Initial>
...
...
lib/RT/Handle.pm
View file @
8c84e38b
...
...
@@ -1208,7 +1208,12 @@ sub InsertData {
my
$sys
=
RT::
System
->
new
(
RT
->
SystemUser
);
for
my
$item
(
@Attributes
)
{
my
$obj
=
delete
$item
->
{
Object
};
# XXX: make this something loadable
my
$obj
=
delete
$item
->
{
Object
};
if
(
ref
$obj
eq
'
CODE
'
)
{
$obj
=
$obj
->
();
}
$obj
||=
$sys
;
my
(
$return
,
$msg
)
=
$obj
->
AddAttribute
(
%$item
);
unless
(
$return
)
{
...
...
t/data/initialdata/initialdata
View file @
8c84e38b
...
...
@@ -69,3 +69,22 @@
Right => 'SeeCustomField',
},
);
@Attributes = ({
Name => 'SavedSearch',
Description => 'New Tickets in Test Queue',
Object => sub {
my $GroupName = 'Test Employees';
my $group = RT::Group->new( RT->SystemUser );
my( $ret, $msg ) = $group->LoadUserDefinedGroup( $GroupName );
die $msg unless $ret;
return $group;
},
Content => {
Query => "Status = 'new' AND Queue = 'Test Queue'",
OrderBy => 'id',
Order => 'DESC'
},
});
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment