[rt-users] absence planning

Eierschmalz, Bernhard Bernhard.Eierschmalz at scheppach.com
Thu Jul 31 07:56:08 EDT 2014


Hi Alex,

Yes, it works now! Great!

Now the second step – to check the state.

I think it should be OK when I change my condition to:
return 0 if $self->Status eq 'open';
my $CFval = $self->TicketObj->OwnerObj->FirstCustomFieldValue(27);
return 1 if defined $CFval and $CFval eq 'yes';

right?

How do I manage to run this scrip before “on correspond open tickets” scrip?


Best Regards
Bernhard

Von: Alex Peters [mailto:alex at peters.net]
Gesendet: Donnerstag, 31. Juli 2014 13:26
An: Eierschmalz, Bernhard; rt-users at lists.bestpractical.com
Betreff: Re: AW: [rt-users] absence planning

I believe that the "Absent" custom field belongs to users rather than tickets.  If that is correct, your code should read as follows:

my $CFval = $self->TicketObj->OwnerObj->FirstCustomFieldValue(27);
return 1 if defined $CFval and $CFval eq 'Yes';

Note that values are case-sensitive, so a capital Y is required.  Does this help?

(P.S.  Please reply-all to ensure that the list remains informed of this discussion.)

On 31 July 2014 21:04, Eierschmalz, Bernhard <Bernhard.Eierschmalz at scheppach.com<mailto:Bernhard.Eierschmalz at scheppach.com>> wrote:
Hallo Alex,

If I understand correctly you mean when the Custom Field is not set, my $CFval will be undefined?
But the custom field for my testuser (who is owner of my test ticket) is set to ‘no’

Could it be that the type of the custom field matters? I have selected “choose one value”. My values are:

Sort

Name

Description

Category

0

Yes

Absent yes

<empty>

1

No

Absent no

<empty>




It seems that either your custom field isn't named precisely "absent", or perhaps you are running an older version of RT which doesn't support loading custom fields by name.  If using the ID (27) works for you, it is probably best to just use that for now.

It is named absent, and I user RT 4.2.6 – but I think anyway it’s better to use the ID.


Best regards
Bernhard

Von: Alex Peters [mailto:alex at peters.net<mailto:alex at peters.net>]
Gesendet: Donnerstag, 31. Juli 2014 12:28
An: Eierschmalz, Bernhard; rt-users at lists.bestpractical.com<mailto:rt-users at lists.bestpractical.com>

Betreff: Re: AW: [rt-users] absence planning

The uninitialized value warnings can be solved by changing the test line:

my $CFval = $self->TicketObj->FirstCustomFieldValue(27);
return 1 if defined $CFval and $CFval eq 'yes';

since when the custom field is not set, $CFval will be undefined.

It seems that either your custom field isn't named precisely "absent", or perhaps you are running an older version of RT which doesn't support loading custom fields by name.  If using the ID (27) works for you, it is probably best to just use that for now.

On 31 July 2014 19:50, Eierschmalz, Bernhard <Bernhard.Eierschmalz at scheppach.com<mailto:Bernhard.Eierschmalz at scheppach.com>> wrote:
Hello Alex,

your idea with 2 scrips running independent of each other sounds good – I will try this.

But first, I still have the problem by loading the CF.
I tried around a little bit – but no solution. I changed my Condition to the following:

my $CFval = $self->TicketObj->FirstCustomFieldValue(27);
return 1 if $CFval eq 'yes';

I receive the following failure:
[12166] [Thu Jul 31 09:37:56 2014] [warning]: Use of uninitialized value $CFval in string eq at (eval 807) line 2. ((eval 807):2)
[12166] [Thu Jul 31 09:37:58 2014] [warning]: Use of uninitialized value $CFval in string eq at (eval 816) line 2. ((eval 816):2)

27 is the ID of my Custom field. When I change to FirstCustomFieldValue(‘absent’) I receive the following failure message:

[12166] [Thu Jul 31 09:49:00 2014] [warning]: Couldn't load custom field by 'absent' identifier (/opt/rt4/sbin/../lib/RT/Record.pm:2231)
[12166] [Thu Jul 31 09:49:00 2014] [warning]: Use of uninitialized value $CFval in string eq at (eval 829) line 2. ((eval 829):2)
[12166] [Thu Jul 31 09:49:06 2014] [warning]: Couldn't load custom field by 'absent' identifier (/opt/rt4/sbin/../lib/RT/Record.pm:2231)
[12166] [Thu Jul 31 09:49:06 2014] [warning]: Use of uninitialized value $CFval in string eq at (eval 838) line 2. ((eval 838):2)

What should I do now?


best Regards,
Bernhard

Von: Alex Peters [mailto:alex at peters.net<mailto:alex at peters.net>]
Gesendet: Freitag, 25. Juli 2014 01:53

An: Eierschmalz, Bernhard
Cc: rt-users at lists.bestpractical.com<mailto:rt-users at lists.bestpractical.com>
Betreff: Re: AW: [rt-users] absence planning


I feel that you are overcomplicating your scrip by testing for a status change (which is actually a side effect of another scrip), because your primary goal is to perform this action when correspondence occurs.

If I were in your position, I would have two scrips in place:

1.  On (correspond AND owner is absent AND ticket is stalled/resolved), set owner to Nobody.  Runs first.

2.  On correspond, open inactive tickets.  Runs second.

Actually, in your position I would probably assign an additional "Exclusive" custom field to tickets that when set to true, indicates that the ticket can only be worked on by the current owner.  Then I would change Scrip 1's condition to "on (correspond AND owner absent AND ticket not exclusive)."  That way, the status isn't used to convey that meaning.

Custom fields can be loaded by name, so that shouldn't be failing for you.  Is "absent" the exact name of the field?  What is the exact code that you are using?
On 25/07/2014 12:44 am, "Eierschmalz, Bernhard" <Bernhard.Eierschmalz at scheppach.com<mailto:Bernhard.Eierschmalz at scheppach.com>> wrote:
Hello Alex,

I user RT 4.2.6
In my error logs I find the following:
[3066] [Thu Jul 24 14:16:20 2014] [warning]: Couldn't load custom field by 'absent' identifier (/opt/rt4/sbin/../lib/RT/Record.pm:2231)
[3066] [Thu Jul 24 14:16:20 2014] [warning]: Use of uninitialized value in string eq at (eval 896) line 1. ((eval 896):1)
[3066] [Thu Jul 24 14:16:23 2014] [warning]: Couldn't load custom field by 'absent' identifier (/opt/rt4/sbin/../lib/RT/Record.pm:2231)
[3066] [Thu Jul 24 14:16:23 2014] [warning]: Use of uninitialized value in string eq at (eval 905) line 1. ((eval 905):1)

What does this mean? Should I identify  the CF by ID?

If I understand you correctly, the "on correspond, open inactive tickets" scrip is interfering with your ability to test whether an absent owner's ticket was previously marked as stalled or resolved rather than open.  If you move your scrip to execute before the scrip that opens inactive tickets on correspond, the interference should no longer occur.

Not exactly. Let me explain once again.
When a user is absent, he maybe has open tickets, and for sure has many resolved and stalled tickets.

The open tickets are tickets, only this user can resolve, and this user decides to resolve this ticket after his absence. (e.g. because this is a large project)
When there is any transaction (e.g. an answer from client or somebody) the owner of this ticket should not be changed (because the owner will resolve it after his absence)
on open tickets the “on correspond, open inactive tickets” isn’t triggered, so the status doesn’t change, and my scrip doesn’t run

Now over to the resolved and stalled tickets: when there is any transaction on these tickets, user should be set to “nobody” to inform the other colleagues about this tickets.
On the transaction, firstly the “on correspond, open inactive tickets” is triggered and changes the state from stalled or resolved to “open”
Now my scrip triggers this status change and changes the user to “nobody”.

I hope you can see my idea more clear now.

best regards
Bernhard


Von: Alex Peters [mailto:alex at peters.net<mailto:alex at peters.net>]
Gesendet: Donnerstag, 24. Juli 2014 16:11
An: Eierschmalz, Bernhard
Cc: rt-users at lists.bestpractical.com<mailto:rt-users at lists.bestpractical.com>
Betreff: Re: [rt-users] absence planning

There might be API inconsistency across RT versions.  What version of RT are you using?  Also, are you receiving any errors in RT's logs when that code runs?

If I understand you correctly, the "on correspond, open inactive tickets" scrip is interfering with your ability to test whether an absent owner's ticket was previously marked as stalled or resolved rather than open.  If you move your scrip to execute before the scrip that opens inactive tickets on correspond, the interference should no longer occur.

On 24 July 2014 23:56, Eierschmalz, Bernhard <Bernhard.Eierschmalz at scheppach.com<mailto:Bernhard.Eierschmalz at scheppach.com>> wrote:
So now I try:
return 1 if $self->TicketObj->FirstCustomFieldValue('absent') eq "yes";

But it still doesn’t work. What is wrong?

I don't understand why you are testing for a ticket status change.  Wouldn't you want the scrip to run only when correspondence occurs?
A user usually changes all his tickets to “stalled” or “resolved” when he’s absent. When the user leaves tickets on “open” during his absence that means, nobody else can finish this ticket, only he can do it (e.g. on larger projects)
So when one of the stalled or resolved tickets receive an answer, the status is changed and with my scrip the user will be nobody.


Best regards,

Bernhard

Von: Alex Peters [mailto:alex at peters.net<mailto:alex at peters.net>]
Gesendet: Donnerstag, 24. Juli 2014 15:33
An: Eierschmalz, Bernhard
Cc: rt-users at lists.bestpractical.com<mailto:rt-users at lists.bestpractical.com>
Betreff: Re: [rt-users] absence planning

You can probably use:

$self->TicketObj->OwnerObj->FirstCustomFieldValue('absent')

to access the value of the owner's "absent" custom field.

I don't understand why you are testing for a ticket status change.  Wouldn't you want the scrip to run only when correspondence occurs?

On 24 July 2014 23:14, Eierschmalz, Bernhard <Bernhard.Eierschmalz at scheppach.com<mailto:Bernhard.Eierschmalz at scheppach.com>> wrote:
Hello,

I want to build some absence planning into our RT to avoid that absent users receive messages and nobody sees this message. What I’m planning is the following:


1.      Creating a user’s custom field “absent” which is yes or no

2.      When a user is absence, this user changes this field to yes, when he’s back he changes back to no

3.      When the status of one ticket with absent owner (where custom field value is “yes”) changes, the owner show be set to nobody (so the other colleagues can find the ticket


so I planned to set up this with a Scrip.
Scrip Action is easy. It’s
$self->TicketObj->SetOwner ( $RT::Nobody->id );
Return 1;



What I’m having problems with is Scrip Condition.

For the first step, I tried to run the scrip on any update, so I only have to check whether the absent-CF is yes or no
I tried the following line:
return 1 if $self->TicketObj->Owner->Customfields->CustomFieldValue(‘absent’) eq “yes”;

but this isn’t working. What is wrong?


A second step will be to check, what exactly was changed (and only run if status was changed).
I think I can do this with
return 0 unless $self->TransactionObj->Type eq “Status”

in front of the other code; am I right?



Best regards,

Bernhard,

--
RT Training - Boston, September 9-10
http://bestpractical.com/training




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20140731/9288451f/attachment.htm>


More information about the rt-users mailing list