[rt-users] accessing role object from template

Shawn Moore shawn at bestpractical.com
Mon May 23 12:53:25 EDT 2016


On 2016年5月21日 at 3:21:17, Woody - Wild Thing Safaris (woody at wildthingsafaris.com) wrote:
> Hi all,

Hi Woody,

> I've created a custom role "Transfer Operators" and i wanted to email
> all those people from a scrip/template, but i have found that the
> argument in ScripActions cannot take a word boundary - renaming the role
> to TransferOperators and the argument in ScripActions sends a mail.

One workaround would be to use the RT::CustomRole-1 syntax (where 1 is the role’s ID) in the ScripAction argument.

I’ve made a ticket for adjusting how the argument parsing works, since you’re right, that is a bit limiting: https://issues.bestpractical.com/Ticket/Display.html?id=31997

> It would seem that either Role Names need to be restricted to single
> words, or Notify.pm needs an update to cope with spaces in Role Names
>  
> My question is however, how can i access Role member info from a template
>  
> something like:
>  
> { $Ticket->RoleObj("TransferOperators")->RealName }

Two options:

Load the role by name:

my $role = RT::CustomRole->new($CurrentUser);
$role->Load(“TransferOperators”);
$Ticket->RoleGroup($role->GroupType);

or specify the internal ID directly:

$Ticket->RoleGroup(“RT::CustomRole-1”);

This will return an RT::Group object. If you only need email address(es), you can use $Ticket->RoleAddresses(“RT::CustomRole-1”) directly.

> w.

By the way, we’d love to hear more about how you’re using custom roles :)

Thanks!
Shawn



More information about the rt-users mailing list