Custom Field Conditions in Template

Hi,

This is what I want to do in my template, in pseudo code:

If Multi-value CF 1 has at least one value
Iterate over all values in CF 1
print each value
End
End

If Multi-value CF 2 has at least one value
Iterate over all values in CF 2
print each value
End
End

I am using the code found at
AddCustomFieldstoTemplates - Request Tracker Wiki to iterate
over and display the multi-valued custom fields. The main problem is, this
only works when both custom fields have at least one value (actually, it’s
broken again now, but it has worked in the past, only under these
conditions).

I don’t know how custom fields are stored (hash, array, etc.), or if they
are initially populated with any values (e.g., a ‘(no value)’ value) or not,
but if did, I could write conditions to skip the while loops and avoid
problems.

Any Ideas about how to do this?
View this message in context: http://www.nabble.com/Custom-Field-Conditions-in-Template-tp15445728p15445728.html

The code you site appears to be correct.

Or even the code you cite. :slight_smile:

Garry T. Williams — 678-370-2438

I am using the code found at
AddCustomFieldstoTemplates - Request Tracker Wiki to iterate
over and display the multi-valued custom fields. The main problem is, this
only works when both custom fields have at least one value (actually, it’s
broken again now, but it has worked in the past, only under these
conditions).

I just ran a test and Ticket::CustomFieldValues() returns an
RT::ObjectCustomFieldValues object for me even when the ticket does
not have a value for the custom field in question. When there is no
value, the first call to RT::ObjectCustomFieldValues::Next() returns
false.

The code you site appears to be correct.

Maybe you need to be more specific about what your code actually is
and what results you actually get.

Garry T. Williams — 678-370-2438

Gary,

Thanks. I’ll copy the actual code to this thread tomorrow (tues 19 feb). I
suspected that the next method should return false (and break the loop) if
there was no value, but the template doesn’t seem to behave this way.
Perhaps it’s because I entered values and then deleted them? Does this
change the value from null to something else?

-Casey

Garry T. Williams-2 wrote:

I am using the code found at
http://wiki.bestpractical.com/view/AddCustomFieldstoTemplates to iterate
over and display the multi-valued custom fields. The main problem is,
this
only works when both custom fields have at least one value (actually,
it’s
broken again now, but it has worked in the past, only under these
conditions).

I just ran a test and Ticket::CustomFieldValues() returns an
RT::ObjectCustomFieldValues object for me even when the ticket does
not have a value for the custom field in question. When there is no
value, the first call to RT::ObjectCustomFieldValues::Next() returns
false.

The code you site appears to be correct.

Maybe you need to be more specific about what your code actually is
and what results you actually get.


Garry T. Williams — 678-370-2438


List info:
The rt-devel Archives

View this message in context: http://www.nabble.com/Custom-Field-Conditions-in-Template-tp15445728p15549585.html

Here’s my template code (edited for privacy). I’m not a perl expert, so you
might see an obvious mistake that I missed.

-------------begin template code-----------------------

{ my $webvalues = $Ticket->CustomFieldValues(‘UI bug tracking link’);
my $datavalues = $Ticket->CustomFieldValues(‘Backend bug tracking link’);
my $OUTPUT;

while ( my $value = ($webvalues->Next) ) {
$OUTPUT .= “UI bug tracking Link: https://somewebsite.com/view.php?id=”;
$OUTPUT .= $value->Content;
$OUTPUT .= “\n”;
}

while ( my $values = ($datavalues->Next) ) {
$OUTPUT .= “Backend bug tracking link:
http://somewebsite2.com/view.php?id=”;
$OUTPUT .= $values->Content;
$OUTPUT .= “\n”;
}

$OUTPUT;
$Transaction->Content();
}

------------end template code-----------

Garry T. Williams-2 wrote:

I am using the code found at
AddCustomFieldstoTemplates - Request Tracker Wiki to iterate
over and display the multi-valued custom fields. The main problem is,
this
only works when both custom fields have at least one value (actually,
it’s
broken again now, but it has worked in the past, only under these
conditions).

I just ran a test and Ticket::CustomFieldValues() returns an
RT::ObjectCustomFieldValues object for me even when the ticket does
not have a value for the custom field in question. When there is no
value, the first call to RT::ObjectCustomFieldValues::Next() returns
false.

The code you site appears to be correct.

Maybe you need to be more specific about what your code actually is
and what results you actually get.


Garry T. Williams — 678-370-2438


List info:
The rt-devel Archives

View this message in context: http://www.nabble.com/Custom-Field-Conditions-in-Template-tp15445728p15579595.html