Communicate a message to web UI from inside Scrip?

As part of my current solution (ongoing) to the “Don’t allow
resolve if a certain CF is not set” topic, I am resetting
the ticket status back to “open” when I see that someone
tried to resolve while the specific CF was not set.

Unfortunately, even though my code set the status back to
"open", the “BriefMessage” on the transaction still says
that the status went from “open to resolved” … yet the
ticket shows properly as open still.

Is there a way to queue one of these notices to the user
from within my Scrip?

 ERROR: Cannot resolve without a value for BlahBlah.

Is there a way to queue one of these notices to the user
from within my Scrip?

ERROR: Cannot resolve without a value for BlahBlah.

Unfortunately, no.

-kevin

More user friendly way to go is to prevent action right in the ui. Look at
mandatory subject extention as example.

Regards, Ruslan. From phone.06.01.2011 21:11 пользователь “Jeff Blaine” jblaine@kickflop.net написал:

As part of my current solution (ongoing) to the “Don’t allow
resolve if a certain CF is not set” topic, I am resetting
the ticket status back to “open” when I see that someone
tried to resolve while the specific CF was not set.

Unfortunately, even though my code set the status back to
"open", the “BriefMessage” on the transaction still says
that the status went from “open to resolved” … yet the
ticket shows properly as open still.

Is there a way to queue one of these notices to the user
from within my Scrip?

ERROR: Cannot resolve without a value for BlahBlah.

More user friendly way to go is to prevent action right in the ui. Look
at mandatory subject extention as example.

I completely agree.

Unfortunately it doesn’t look very doable so far.

Here’s what I’ve got to say after 4 hours.

“Mandatory Subject Extension” works because there’s a clear
hook (and flag, $skip_create) available in the callback calls.

There are 2 places that we care about where resolving a ticket
can happen:

Update.html (via clicking the ‘Resolve’ action link)

Modify.html (via clicking ‘Basics’)

Oddity: Update.html redirects to Display.html on success.

     Modify.html redisplays Modify.html on success.

Here are my notes (as comments) on these two files:

Modify.html

 # This one doesn't even have a CallbackName (???)
 # How do I make my own Callback?  Proper path for that?
 $m->callback( TicketObj => $TicketObj,
               CustomFields => $CustomFields,
               ARGSRef => \%ARGS );

Update.html

 ...

 $m->callback( Ticket => $TicketObj, ARGSRef => \%ARGS,
              results => \@results, CallbackName => 'Initial' );
 ...

 if ( !$checks_failure && exists $ARGS{SubmitTicket} ) {
     $m->callback( Ticket => $TicketObj, ARGSRef => \%ARGS,
                   CallbackName => 'BeforeDisplay' );
     # All okay -- Complete jump to Display.html and not
     # passing along @results, yet SOMEHOW Display.html
     # shows what was performed.  Mystery to me.
     return $m->comp('Display.html', TicketObj => $TicketObj,
                     %ARGS);
 }
 # ELSE Update.html is called and shows the failed hardcoded
 # checks*it* cared about.
 # This blows, because if the hardcoded checks are okay
 # (but not MY checks), we jump to a completely different
 # page.
 # What would work, I think, is if the "Initial" callback
 # passed $checks_failure so that I could check what I
 # wanted and set $checks_failure to 1 (and update @results)
 # as I saw fit.

Along with all of that, I can’t seem to get even a basic callback
working for the life of me.

I have tried all sorts of variations on the following, with
server restarts, and gotten nowhere:

/rt/local/html/Callbacks/MyCallbacks/Ticket/TheFile.html/TheCallbackName

Where TheFile.html is something like Update.html

Where TheCallbackName is something like Initial

How about put a comment with your script in the ticket.
The Ticket history would then look like this:

  • Status change from open to resolve
  • Comment: ERROR: Cannot resolve without a value for BlahBlah.
  • Status change from resolved to open

I think this would make it clear for the user why they can’t resolve the
ticket.

-ChrisAm 06.01.2011 19:10, schrieb Jeff Blaine:

As part of my current solution (ongoing) to the “Don’t allow
resolve if a certain CF is not set” topic, I am resetting
the ticket status back to “open” when I see that someone
tried to resolve while the specific CF was not set.

Unfortunately, even though my code set the status back to
"open", the “BriefMessage” on the transaction still says
that the status went from “open to resolved” … yet the
ticket shows properly as open still.

Is there a way to queue one of these notices to the user
from within my Scrip?

ERROR: Cannot resolve without a value for BlahBlah.

How about put a comment with your script in the ticket.
The Ticket history would then look like this:

  • Status change from open to resolve
  • Comment: ERROR: Cannot resolve without a value for BlahBlah.
  • Status change from resolved to open

That’s exactly what I am trying to do :slight_smile:

I don’t want to do it way down in the history though. The
user should be notified at the top of the screen where normal
operation status messages go.

Pulling my hair out here. Why is this callback not being
tickled? I see nothing in my logs.

RT 3.8.7

Mason cache cleared and server restarted a million times.

The call to the callback in Ticket/Display.html is:

 $m->callback(
     CallbackName => 'BeforeDisplay',
     TicketObj => \$TicketObj,
     Tickets => \$Tickets,
     Actions => \@Actions,
     ARGSRef => \%ARGS,
 );

And my setup is:

[root@rtdev1 Display.html]# pwd
/rt/local/html/Callbacks/MyCallbacks/Ticket/Display.html
[root@rtdev1 Display.html]# ls -l BeforeDisplay
-rw-r–r-- 1 rt root 689 Jan 6 22:06 BeforeDisplay
[root@rtdev1 Display.html]# cat BeforeDisplay
<%INIT>
$RT::Logger->info(“In Callback/Display.html/BeforeDisplay\n”);
return 1;
</%INIT>
<%ARGS>
$Actions => []
</%ARGS>

I don’t see anything wrong, but perhaps you might review here:

maybe soemthing will jump out at you that I don’t see.

Also, just to check – I don’t think the default logging is at info level – gets a bit chatty. Is it possible you are not seeing it just because you are not logging that level?

IN your etc/RT_SIteConfig file you should have something like: ?

Logging

Set($LogToSyslog , ‘info’);

Set($LogToScreen , ‘info’);

Set($LogToFile , 1);

Set($LogDir, ‘var/log’);

Set($LogToFileNamed , “rt.log”); #log to rt.log

Set($LogStackTraces, ‘’);

Set(@LogToSyslogConf, ());

Set($StatementLog, ‘’);

End logging-----Original Message-----

From: rt-users-bounces@lists.bestpractical.com [mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Jeff Blaine
Sent: Thursday, January 06, 2011 10:17 PM
To: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Communicate a message to web UI from inside Scrip?

Pulling my hair out here. Why is this callback not being

tickled? I see nothing in my logs.

RT 3.8.7

Mason cache cleared and server restarted a million times.

The call to the callback in Ticket/Display.html is:

 $m->callback(

     CallbackName => 'BeforeDisplay',

     TicketObj => \$TicketObj,

    Tickets => \$Tickets,

     Actions => \@Actions,

     ARGSRef => \%ARGS,

 );

And my setup is:

[root@rtdev1 Display.html]# pwd

/rt/local/html/Callbacks/MyCallbacks/Ticket/Display.html

[root@rtdev1 Display.html]# ls -l BeforeDisplay

-rw-r–r-- 1 rt root 689 Jan 6 22:06 BeforeDisplay

[root@rtdev1 Display.html]# cat BeforeDisplay

<%INIT>

$RT::Logger->info(“In Callback/Display.html/BeforeDisplay\n”);

return 1;

</%INIT>

<%ARGS>

$Actions => []

</%ARGS>

This e-mail message is intended only for the personal use of the recipient(s) named above. If you are not an intended recipient, you may not review, copy or distribute this message. If you have received this communication in error, please notify the Hearst Service Center (cadmin@hearstsc.com) immediately by email and delete the original message.

I don’t see anything wrong, but perhaps you might review here:

http://requesttracker.wikia.com/wiki/CustomizingWithCallbacks

Heh, I’ve read everything there no less than 3 times in the last
24 hours :slight_smile: I suppose another time can’t hurt, but IMO this
is all really poorly documented.

maybe soemthing will jump out at you that I don’t see.

Also, just to check – I don’t think the default logging is at info level
– gets a bit chatty. Is it possible you are not seeing it just because
you are not logging that level?

IN your etc/RT_SIteConfig file you should have something like: ?

Yup, all set there, as I get other RT syslog messages.

I even changed my $RT::Logger->info call to “crit”. No dice.

I succeed with $RT::Logger->info(“TESTING”); from a Scrip just
fine.

Hi Jeff:

Stupid question by where did you put your callback call??
I added

% $m->callback(CallbackName => ‘BeforeDisplay’,TicketObj => $TicketObj,Tickets => $Tickets,Actions => @Actions,ARGSRef => %ARGS);

Just above :
% $m->callback(CallbackName => ‘BeforeActionList’, %ARGS, Actions => @Actions, ARGSRef => %ARGS, Ticket => $TicketObj);

And it works:
[Fri Jan 7 14:31:09 2011] [debug]: In Callback/Display.html/BeforeDisplay (/opt/rt3/local/html/Callbacks/MyCallbacks/Ticket/Display.html/BeforeDisplay:3)

By the way going back to your original query regarding not allowing closure until certain CFs are populated, I had to do something similar a couple of months back using a different approach , the way I done it is by not including @InactiveStatus list if these CFs are not populated, so basically modifying
local/html/Elements/SelectStatus
if ($CanResolve == 0) {
@status = RT->Config->Get(‘ActiveStatus’) ;
push @status,“deleted” ;
} else {
@status = $queue->StatusArray();
}

$CanResolve is a variable pushed to the SelectStatus from various pages such as Update.html, Modify.html , Display.html etc …
It included changes in few places, I had very little time to do it in (1 day), so did not use callbacks, if you are interested I can send you more details.
I’ve been following this thread hoping to use whatever you come up with if its better.

Regards;
Roy

[root@rtdev1 Display.html]# ls -l BeforeDisplay
-rw-r–r-- 1 rt root 689 Jan 6 22:06 BeforeDisplay

Can your web user read this file?

-kevin

Hi Jeff:

Stupid question by where did you put your callback call??
I added

% $m->callback(CallbackName => ‘BeforeDisplay’,TicketObj => $TicketObj,Tickets => $Tickets,Actions => @Actions,ARGSRef => %ARGS);

Just above :
% $m->callback(CallbackName => ‘BeforeActionList’, %ARGS, Actions => @Actions, ARGSRef => %ARGS, Ticket => $TicketObj);

And it works:
[Fri Jan 7 14:31:09 2011] [debug]: In Callback/Display.html/BeforeDisplay (/opt/rt3/local/html/Callbacks/MyCallbacks/Ticket/Display.html/BeforeDisplay:3)

Hi Roy,

I didn’t “put a callback call” anywhere. I am using the
default callback calls in the RT source.

That is:

/rt/share/html/Ticket/Display.html has stock RT callback calls.

My code:

/rt/local/html/Callbacks/MyCallbacks/Ticket/Display.html/BeforeDisplay

references those. See below:

The call to the callback in Ticket/Display.html is:

  $m->callback(
      CallbackName =>  'BeforeDisplay',
      TicketObj =>  \$TicketObj,
      Tickets =>  \$Tickets,
      Actions =>  \@Actions,
      ARGSRef =>  \%ARGS,
  );

That’s stock RT code in Ticket/Display.html

Am I missing some concept/idea you’re trying to show me?

Thanks!

[root@rtdev1 Display.html]# ls -l BeforeDisplay
-rw-r–r-- 1 rt root 689 Jan 6 22:06 BeforeDisplay

Can your web user read this file?

Every directory from (and including) /rt/local downward
is world readable and executable/traversable.

The file, as above, is world readable.

Jeff,

That’s why I have my scrip put “NOT SET CORRECTLY” in CAPS as a value in the
CF. The ticket display will show the CF and the CAPS will STAND OUT and make
it easier for the user to see what’s up. The Email serves as a reminder to
set the CF. Therefore, the user gets reminded two different ways.

Kenn
LBNLOn Thu, Jan 6, 2011 at 1:57 PM, Christian Loos cloos@netsandbox.de wrote:

How about put a comment with your script in the ticket.
The Ticket history would then look like this:

  • Status change from open to resolve
  • Comment: ERROR: Cannot resolve without a value for BlahBlah.
  • Status change from resolved to open

I think this would make it clear for the user why they can’t resolve the
ticket.

-Chris

Am 06.01.2011 19:10, schrieb Jeff Blaine:

As part of my current solution (ongoing) to the “Don’t allow
resolve if a certain CF is not set” topic, I am resetting
the ticket status back to “open” when I see that someone
tried to resolve while the specific CF was not set.

Unfortunately, even though my code set the status back to
"open", the “BriefMessage” on the transaction still says
that the status went from “open to resolved” … yet the
ticket shows properly as open still.

Is there a way to queue one of these notices to the user
from within my Scrip?

ERROR: Cannot resolve without a value for BlahBlah.

Still no luck. Can anyone suggest how I might debug why
this isn’t working? I’m begging at this point :slight_smile: Here’s
the most complete picture I can paint for you right now:

The following entire directory structure is set “drwxr-xr-x”

/rt/local/
|-- html/
|---- Callbacks/
|---- MyCallbacks/
|----- Ticket/
|-- Display.html/

pwd

/rt/local/html/Callbacks/MyCallbacks/Ticket/Display.html

ls -l BeforeDisplay

-rw-r–r-- 1 rt root 668 Jan 6 22:19 BeforeDisplay

cat BeforeDisplay

<%INIT>
$RT::Logger->crit(“In Display.html/BeforeDisplay\n”);
return 1;
</%INIT>
<%ARGS>
$Actions => []
</%ARGS>

/etc/init.d/rtsrv1dev-httpd restart

Stopping httpd: httpd
Starting httpd: httpd

Login to site. Here you can see that various calls to RT::Logger
do log to /var/log/messages

 Jan 10 16:26:25 rtdev1 RT: Successful login for jblaine from
 xx.xx.5.133 (/rt/bin/../lib/RT/Interface/Web.pm:430)

View ticket, resolve ticket, again proof that logging can happen:

 Jan 10 16:27:11 rtdev1 RT: Apache2::RequestIO::rflush: (103)
 Software caused connection abort at /usr/lib/perl5/site_perl/5.8.8
 /HTML/Mason/ApacheHandler.pm line 1020 (/rt/bin/webmux.pl:168)

Re-open ticket, resolve ticket, view ticket over and over…

 [ nothing ]

If I then add the following to the callback code (inside
the INIT block), nothing is ever written out to /tmp/jblaine.txt:

 open (GRRR, '>>/tmp/jblaine.txt');
 print GRRR "HELLO?\n";
 close (GRRR);

So the code is never even getting executed.

If I then ‘cp BeforeDisplay BeforeActionList’ and also
’cp BeforeDisplay BeforeShowSummary’ to create two more
callback tests, in order to prove that it’s not just the
callback for BeforeDisplay that is broken … those do
not work either (after a server restart of course).On 1/7/2011 10:03 AM, Jeff Blaine wrote:

On 1/7/2011 9:56 AM, Kevin Falcone wrote:

On Thu, Jan 06, 2011 at 10:16:55PM -0500, Jeff Blaine wrote:

ls -l BeforeDisplay

-rw-r–r-- 1 rt root 689 Jan 6 22:06 BeforeDisplay

Can your web user read this file?

Every directory from (and including) /rt/local downward
is world readable and executable/traversable.

The file, as above, is world readable.

Just curious - did you at any time clear the mason cache?

http://requesttracker.wikia.come/wiki/CleanMasonCache

When you change anything in local/html, you have to clear the cache to see the changes

ScottFrom: rt-users-bounces@lists.bestpractical.com [mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Jeff Blaine
Sent: Monday, January 10, 2011 4:59 PM
To: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Communicate a message to web UI from inside Scrip?

Still no luck. Can anyone suggest how I might debug why
this isn’t working? I’m begging at this point :slight_smile: Here’s
the most complete picture I can paint for you right now:

The following entire directory structure is set “drwxr-xr-x”

/rt/local/
|-- html/
|---- Callbacks/
|---- MyCallbacks/
|----- Ticket/
|-- Display.html/

pwd

/rt/local/html/Callbacks/MyCallbacks/Ticket/Display.html

ls -l BeforeDisplay

-rw-r–r-- 1 rt root 668 Jan 6 22:19 BeforeDisplay

cat BeforeDisplay

<%INIT>
$RT::Logger->crit(“In Display.html/BeforeDisplay\n”);
return 1;
</%INIT>
<%ARGS>
$Actions => []
</%ARGS>

/etc/init.d/rtsrv1dev-httpd restart

Stopping httpd: httpd
Starting httpd: httpd

Login to site. Here you can see that various calls to RT::Logger
do log to /var/log/messages

 Jan 10 16:26:25 rtdev1 RT: Successful login for jblaine from
 xx.xx.5.133 (/rt/bin/../lib/RT/Interface/Web.pm:430)

View ticket, resolve ticket, again proof that logging can happen:

 Jan 10 16:27:11 rtdev1 RT: Apache2::RequestIO::rflush: (103)
 Software caused connection abort at /usr/lib/perl5/site_perl/5.8.8
 /HTML/Mason/ApacheHandler.pm line 1020 (/rt/bin/webmux.pl:168)

Re-open ticket, resolve ticket, view ticket over and over…

 [ nothing ]

If I then add the following to the callback code (inside
the INIT block), nothing is ever written out to /tmp/jblaine.txt:

 open (GRRR, '>>/tmp/jblaine.txt');
 print GRRR "HELLO?\n";
 close (GRRR);

So the code is never even getting executed.

If I then ‘cp BeforeDisplay BeforeActionList’ and also
’cp BeforeDisplay BeforeShowSummary’ to create two more
callback tests, in order to prove that it’s not just the
callback for BeforeDisplay that is broken … those do
not work either (after a server restart of course).

Yup, sorry, I forgot to mention that. Doesn’t help :confused:

rm -rf /rt/var/mason_data/obj/*On 1/11/2011 9:57 AM, Lander, Scott wrote:

Just curious - did you at any time clear the mason cache?

http://requesttracker.wikia.come/wiki/CleanMasonCache

When you change anything in local/html, you have to clear the cache to see the changes

Scott

-----Original Message-----
From: rt-users-bounces@lists.bestpractical.com [mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Jeff Blaine
Sent: Monday, January 10, 2011 4:59 PM
To: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Communicate a message to web UI from inside Scrip?

Still no luck. Can anyone suggest how I might debug why
this isn’t working? I’m begging at this point :slight_smile: Here’s
the most complete picture I can paint for you right now:

The following entire directory structure is set “drwxr-xr-x”

/rt/local/
|-- html/
|---- Callbacks/
|---- MyCallbacks/
|----- Ticket/
|-- Display.html/

pwd

/rt/local/html/Callbacks/MyCallbacks/Ticket/Display.html

ls -l BeforeDisplay

-rw-r–r-- 1 rt root 668 Jan 6 22:19 BeforeDisplay

cat BeforeDisplay

<%INIT>
$RT::Logger->crit(“In Display.html/BeforeDisplay\n”);
return 1;
</%INIT>
<%ARGS>
$Actions => []
</%ARGS>

/etc/init.d/rtsrv1dev-httpd restart

Stopping httpd: httpd
Starting httpd: httpd

Login to site. Here you can see that various calls to RT::Logger
do log to /var/log/messages

  Jan 10 16:26:25 rtdev1 RT: Successful login for jblaine from
  xx.xx.5.133 (/rt/bin/../lib/RT/Interface/Web.pm:430)

View ticket, resolve ticket, again proof that logging can happen:

  Jan 10 16:27:11 rtdev1 RT: Apache2::RequestIO::rflush: (103)
  Software caused connection abort at /usr/lib/perl5/site_perl/5.8.8
  /HTML/Mason/ApacheHandler.pm line 1020 (/rt/bin/webmux.pl:168)

Re-open ticket, resolve ticket, view ticket over and over…

  [ nothing ]

If I then add the following to the callback code (inside
the INIT block), nothing is ever written out to /tmp/jblaine.txt:

  open (GRRR, '>>/tmp/jblaine.txt');
  print GRRR "HELLO?\n";
  close (GRRR);

So the code is never even getting executed.

If I then ‘cp BeforeDisplay BeforeActionList’ and also
’cp BeforeDisplay BeforeShowSummary’ to create two more
callback tests, in order to prove that it’s not just the
callback for BeforeDisplay that is broken … those do
not work either (after a server restart of course).

On 1/7/2011 10:03 AM, Jeff Blaine wrote:

On 1/7/2011 9:56 AM, Kevin Falcone wrote:

On Thu, Jan 06, 2011 at 10:16:55PM -0500, Jeff Blaine wrote:

ls -l BeforeDisplay

-rw-r–r-- 1 rt root 689 Jan 6 22:06 BeforeDisplay

Can your web user read this file?

Every directory from (and including) /rt/local downward
is world readable and executable/traversable.

The file, as above, is world readable.


This e-mail message is intended only for the personal use of the recipient(s) named above. If you are not an intended recipient, you may not review, copy or distribute this message. If you have received this communication in error, please notify the Hearst Service Center (cadmin@hearstsc.com) immediately by email and delete the original message.

Still no luck. Can anyone suggest how I might debug why
this isn’t working? I’m begging at this point :slight_smile: Here’s
the most complete picture I can paint for you right now:

You can instrument the callback method that looks for these, but it is
also worth checking in Configuration -> Tools -> System Configuration
that you’re using the correct Mason roots.

I’ve also seen selinux prevent access to files that should otherwise
be readable.

-kevin

Still no luck. Can anyone suggest how I might debug why
this isn’t working? I’m begging at this point :slight_smile: Here’s
the most complete picture I can paint for you right now:

You can instrument the callback method that looks for these, but it is
also worth checking in Configuration -> Tools -> System Configuration
that you’re using the correct Mason roots.

WINNER! Thank you very much (and everyone else who threw out
ideas).

Phew.