[rt-users] sending mail from scrip action
Hi, I would like to send e-mails from the scrip preparation code. I use require RT::Action::SendEmail; use strict; use vars qw/@ISA/; @ISA = qw(RT::Action::SendEmail); and would like to set $self->SetTemplate(25); but against my expectation $self is not the scrip object but Action::UserDefined which does not allow setting the template. At the end I would send the mail by @{ $self->{'To'} } = $followerEmail; $self->SUPER::Prepare(); $self->SUPER::Commit(); If I do not set the template, then the ::Prepare call does not work, lacking the TemplateObj. How could I do this properly? - Gergely
[rt-users] array of users from Users object
Hi there, how can I create an array of User objects from a Users object? I do my $group = RT::Group->new($ticket->OwnerObj); $RT::Logger->info("OnCreate: group->Name=" . $group->Name); $group->LoadUserDefinedGroup($name); $RT::Logger->info("OnCreate: group->Name=" . $group->Name); my @groupmembers = $group->UserMembersObj; but that does not seem to work. - Gergely
Re: [rt-users] User only load by E-mail or by id
> you can only load a user by id or by E-mail address. The routine is > LoadByEmail. At last a friend suggested my $user = RT::User->new( RT->SystemUser ); $user->Load('test_user'); and it worked. - Gergely
[rt-users] CustomFieldValues
Hi there, I was able to log a custom field value in a scrip: my $user=$self->TransactionObj->CreatorObj; my $cfvs = $user->CustomFieldValues('107'); while(my $cfv = $cfvs->Next) { $RT::Logger->info("cfv->Content=" . $cfv->Content) if length $cfv->Content; } return 1; Beside ->Content, is there a field that gives back the number I set in the custom field definition? It would be more robust to handle. - Gergely
[rt-users] scrip not logging
Hi there, my scrip is logged, but my logging commands do not result in a log line. Here is the log the system prints upon its start: Aug 13 17:23:04 dox RT: #2211/33968 - Scrip 23 Email dummy (/opt/rt4/sbin/../lib/RT/Action/SendEmail.pm:301) But the following condition does not write the any log: $RT::Logger->info("Hello RT World!"); my $cf=$self->TransactionObj->CreatorObj->LoadCustomFieldByIdentifier('107'); my $cf2 = $session->{'CurrentUser'}->UserObj->FirstCustomFieldValue('107'); $RT::Logger->info("cf=$cf"); $RT::Logger->info("cf2=$cf2"); return 1; What is the problem with the above code? - Gergely
Re: [rt-users] putting a custom field in place
Kevin Falcone wrote: >> I cleared the cache and restarted apache but only the "When to e-mail" >> label appeared but not the multiple checkboxes. What else should I do >> to make it happen? I filled in the multiple possible options for the >> custom field. > > I suggest adding some error checking around your Load and checking the > apache error logs. Also, ensure that the CF is applied globally and > that rights have been granted to allow editing. You are right, the rights were missing. - Gergely
[rt-users] getting a multiple valued custom field
Hi there, how can I get the values from a "select multiple values" typed checkbox in a scrip condition? If possible, I would be interested in doing the same in a standalone script. How can I access a user object from a standalone script? - Gergely
Re: [rt-users] accessing custom fields
>> I have created a custom field for a User. How can I access it from a >> perl script? I have the CF id, that's clear, but some of the code I >> have found had referred to some queue which I wonder about as I want a >> core User custom field, not related to any queue. > > my $cf_value = > $self->TransactionObj->CreatorObj->FirstCustomFieldValue('Client'); > > I used above in OnCreate scrip. Hope that helps. Seems fine, but what is the $self? I guess it is set by the general scrip beginning but how can I create it from a standalone scrip_t_? - Gergely
[rt-users] accessing custom fields
Hi, I have created a custom field for a User. How can I access it from a perl script? I have the CF id, that's clear, but some of the code I have found had referred to some queue which I wonder about as I want a core User custom field, not related to any queue. - Gergely
[rt-users] RT::User problem
Hi there, I would like to create a User object through the Load method. The documentation writes: "Load a user object from the database. Takes a single argument. If the argument is numerical, load by the column 'id'. If a user object or its subclass passed then loads the same user by id. Otherwise, load by the "Name" column which is the user's textual username." #!/usr/bin/perl use strict; use lib "/opt/rt4/lib"; use lib "/opt/rt4/local/lib"; use RT; use RT::User; RT->LoadConfig; RT->Init; my $test_user = RT::User::Load('b...@buday-rd.hu'); printf "\$test_user=", $test_user; my @to = $test_user->EmailAddress; for $a (0 .. $#to) { print $to[$a], "\n"; } Running this script with sudo makes it say [Mon Aug 13 11:16:47 2012] [crit]: Can't call method "EmailAddress" on an undefined value at ./email.pl line 13. (/opt/rt4/lib/RT.pm:341) Can't call method "EmailAddress" on an undefined value at ./email.pl line 13. The username I used in the place of m...@company.com is indeed a valid user name. What is the problem then? - Gergely
[rt-users] testing perl script in RT
Hi there, how can I run a perl script through the RT environment so that I can use the database and all the modules, but see the compiler output on my faulty experiments? - Gergely
[rt-users] putting a custom field in place
Hi there, I would like to have a "select multiple values" type custom field in an extension of RT, The previous custom field works, it is about choosing languages, so the same type. I created a custom field following this working example. I set it to Global, following again the example. I put some new code into UserPrefs.html: UserPrefs.html:% my $UserWhenEmail = RT::CustomField->new($session{'CurrentUser'}); UserPrefs.html:% $UserWhenEmail->Load(107); where 107 is the id for this new custom field. Also I wrote <&|/l&>When to e-mail: <& /Elements/EditCustomField, %ARGS, Object => $UserObj, CustomField => $UserWhenEmail &> I cleared the cache and restarted apache but only the "When to e-mail" label appeared but not the multiple checkboxes. What else should I do to make it happen? I filled in the multiple possible options for the custom field. - Gergely