Modifying a custom role in a custom action

Hello, I am trying to write a very simple custom Scrip which adds a value to a custom role, when a custom field is changed.

My current Scrip looks like this, but does not work. I think there must be something different about using custom roles vs built in roles, because if I change the “Type” to “Cc”, the Scrip works perfectly. Is there something I’m missing for changing the value of a custom role?

$self->TicketObj->AddWatcher(
Type=> ‘escalations’ ,
Email => ‘internalescalation@logicomusa.net’
);

1;

You need to get the type from the custom role object:

my $custom_role = RT::CustomRole->new( RT->SystemUser );
my ($ret, $msg) = $custom_role->Load( 'Test' );
unless ( $ret ) {
    RT::Logger->error( "Could not load custom role 'Test': $msg" );
    return;
}

$self->TicketObj->AddWatcher(
    Type=> $custom_role->GroupType,
    Email => 'internalescalation@logicomusa.net'
);

1;

That worked perfectly! Thank you very much!

Small follow-up question. Is it possible to use a custom role as a search term?

(Created = ‘today’) AND ((escalations.EmailAddress = ‘internalescalation@logicomusa.net’))

I tried using this as an advanced search and am getting an error.

Queue = 'General' AND CustomRole.{Test}.EmailAddress LIKE ''

That worked for me, thank you so much!