[rt-users] Callback with no TicketObject arg, guidance needed
Jeff Blaine
jblaine at kickflop.net
Thu Mar 20 17:28:06 EDT 2014
Alex, thanks again. I promise to write up what I've learned in the last
week (wiki).
I've hit another wall. While I can prove that the callback I am using is
in the right spot and is called...
The following Limit() IS working for Modify.html hits
(EditCustomFields). That is, hide certain fields for editing when a
control flag (CF) is set a certain way.
The following Limit() is NOT working for *Display.html*
(ShowCustomFields) hits. That is, hide certain fields from display when
a control flag (CF) is set a certain way. The problem is, they are still
showing when the control flag is set to not show them.
The code in both callback files is the same.
>> How might I exclude fields X, Y, Z from $CustomFields in my callback?
>
> # Repeat for each name to exclude:
> $CustomFields->Limit(
> FIELD => 'Name',
> OPERATOR => '!=',
> VALUE => 'SomeNameToExclude',
> ENTRYAGGREGATOR => 'AND',
> );
Here is local/html/Elements/ShowCustomFields/MassageCustomFields (right
spot?) with comments relevant here:
<%args>
$CustomFields => undef
$ARGS => undef
$Object => undef
</%args>
<%init>
#------------------------------------------------------------------
# NOTE: If I enable these 4 short-circuit lines, Display.html does
# in fact only show the 'Scope' custom field as a control/test.
# So a) the callback location seems correct and b) it proves we can
# at least control the contents of $CustomFields.
#
# $CustomFields->Limit(FIELD => 'Name', OPERATOR => '=',
# VALUE => 'Scope', ENTRYAGGREGATOR => 'AND',
# CASESENSITIVE => 0);
# return;
#------------------------------------------------------------------
my $ticket = $ARGS{'Object'};
# The fields to hide unless 'Noteworthy = Yes'
my @childfields = ("Details", "Response", "Total emails");
# Default to showing all fields in @childfields
my $showchildren = 1;
# Determine whether to show child fields or not
while (my $cf = $CustomFields->Next) {
my $nam = $cf->Name;
my $val = $ticket->FirstCustomFieldValue($nam);
if ($nam =~ /^noteworthy$/i and $val !~ /^yes$/i) {
$showchildren = 0;
last;
}
}
if (! $showchildren) {
# In theory, this should exclude all fields in @childfields
$CustomFields->Limit(FIELD => 'Name', OPERATOR => '!=', VALUE =>
'$_', ENTRYAGGREGATOR => 'AND', CASESENSITIVE => 0) for (@childfields);
}
</%init>
%# EOF
More information about the rt-users
mailing list