Adding custom field type, how to force single value

I’m adding a custom field type tp my RT instance to that I can create
custom Show and Edit templates due to the data being stored in JSON.

What I’;ve found so far is that RT thinks my Text-based CF is multivalued,
and when the edit side submits any values (not even changing any of the
json), RT will parse pretty-printed JSON as multiple entries.

How does one typically go about informing RT that the new custom field type
is single-valued?

Thanks,
Len.

lenjaffe@jaffesystems.com 614-404-4214 @lenjaffe
Information Technology Smoke Jumper, Host of Columbus Code Jam
http://www.meetup.com/techlifecolumbus/
www.lenjaffe.com http://www.theycomewithcheese.com
Advent Planet http://www.lenjaffe.com/AdventPlanet/ - An Aggregation of
Online Advent Calendars.

I’m adding a custom field type tp my RT instance to that I can create custom
Show and Edit templates due to the data being stored in JSON.

What I’;ve found so far is that RT thinks my Text-based CF is multivalued, and
when the edit side submits any values (not even changing any of the json), RT
will parse pretty-printed JSON as multiple entries.

How does one typically go about informing RT that the new custom field type is
single-valued?

I assume you’ve actually made a Freeform rather than Text CF with
custom viewers/editors. The relevant setting should be MaxValues, but
switching your type is likely what you want - Fill in one text area vs
enter multiple values.

-kevin

I’m adding a custom field type tp my RT instance to that I can create
custom
Show and Edit templates due to the data being stored in JSON.

What I’;ve found so far is that RT thinks my Text-based CF is
multivalued, and
when the edit side submits any values (not even changing any of the
json), RT
will parse pretty-printed JSON as multiple entries.

How does one typically go about informing RT that the new custom field
type is
single-valued?

I assume you’ve actually made a Freeform rather than Text CF with
custom viewers/editors. The relevant setting should be MaxValues, but
switching your type is likely what you want - Fill in one text area vs
enter multiple values.

This was an attempt to create my own custom field type, based on the ‘fill
in one text area’ text CF.

I’ll look at freeform.

Thank you.

Len.
lenjaffe@jaffesystems.com 614-404-4214 @lenjaffe
Information Technology Smoke Jumper, Host of Columbus Code Jam
http://www.meetup.com/techlifecolumbus/
www.lenjaffe.com http://www.theycomewithcheese.com
Advent Planet http://www.lenjaffe.com/AdventPlanet/ - An Aggregation of
Online Advent Calendars.

In order make sure that we’re solving the correct problem, since my
previous post was terse, and I’m not sure whether I used all the right key
words, please allow me to elaborate:

Based on a similar treatment by a colleague, I have created
local/html/Elements/CustomField_Local.pm

15 #$FieldTypes{JSON_Encoded_Resource_Field} = {
16 # sort_order => 36,
17 # selection_type => 0,
18 #
19 # labels => [
20 # ‘Fill in one Encoded Resource Text Area’,
21 # ],
22 #};

The I
created local/html/Elements/EditCustomFieldJSON_Encoded_Resource_Field and
local/html/Elements/ShowCustomFieldJSON_Encoded_Resource_Field

Which do what I need them to - pretty print the JSON so a human can read it
and edit it if necessary.

But RT thinks this custom field type allows multiple entries per field, and
so pukes all over the pretty-printed JSON.

When I use a straight “Fill in one text area” RT is ok with the JSON, but
the JSON is not pretty printed.

Thank you again.

Len.On Tue, Jun 17, 2014 at 3:46 PM, Len Jaffe lenjaffe@jaffesystems.com wrote:

On Tue, Jun 17, 2014 at 3:11 PM, Kevin Falcone falcone@bestpractical.com wrote:

On Mon, Jun 16, 2014 at 04:54:03PM -0400, Len Jaffe wrote:

I’m adding a custom field type tp my RT instance to that I can create
custom
Show and Edit templates due to the data being stored in JSON.

What I’;ve found so far is that RT thinks my Text-based CF is
multivalued, and
when the edit side submits any values (not even changing any of the
json), RT
will parse pretty-printed JSON as multiple entries.

How does one typically go about informing RT that the new custom field
type is
single-valued?

I assume you’ve actually made a Freeform rather than Text CF with
custom viewers/editors. The relevant setting should be MaxValues, but
switching your type is likely what you want - Fill in one text area vs
enter multiple values.

This was an attempt to create my own custom field type, based on the ‘fill
in one text area’ text CF.

I’ll look at freeform.

Thank you.

Len.

lenjaffe@jaffesystems.com 614-404-4214 @lenjaffe
Information Technology Smoke Jumper, Host of Columbus Code Jam
http://www.meetup.com/techlifecolumbus/
www.lenjaffe.com http://www.theycomewithcheese.com
Advent Planet http://www.lenjaffe.com/AdventPlanet/ - An Aggregation of
Online Advent Calendars.

lenjaffe@jaffesystems.com 614-404-4214 @lenjaffe
Information Technology Smoke Jumper, Host of Columbus Code Jam
http://www.meetup.com/techlifecolumbus/
www.lenjaffe.com http://www.theycomewithcheese.com
Advent Planet http://www.lenjaffe.com/AdventPlanet/ - An Aggregation of
Online Advent Calendars.

In order make sure that we’re solving the correct problem, since my previous
post was terse, and I’m not sure whether I used all the right key words, please
allow me to elaborate:

Based on a similar treatment by a colleague, I have created local/html/Elements
/CustomField_Local.pm

That is not the right place for a Foo_Local.pm, they go in
local/lib/RT/

The I created local/html/Elements/EditCustomFieldJSON_Encoded_Resource_Field
and local/html/Elements/ShowCustomFieldJSON_Encoded_Resource_Field

Which do what I need them to - pretty print the JSON so a human can read it and
edit it if necessary.

But RT thinks this custom field type allows multiple entries per field, and so
pukes all over the pretty-printed JSON.

When I use a straight “Fill in one text area” RT is ok with the JSON, but the
JSON is not pretty printed.

In that case, you could use Fill in one text area for editing and just
override display using the callbacks in ShowCustomField based on the
CF name.

Otherwise, look into the MaxValues setting.

-kevin

In order make sure that we’re solving the correct problem, since my
previous
post was terse, and I’m not sure whether I used all the right key words,
please
allow me to elaborate:

Based on a similar treatment by a colleague, I have created
local/html/Elements
/CustomField_Local.pm

That is not the right place for a Foo_Local.pm, they go in
local/lib/RT/

Indeed. That is where it lives. I misspoke above.

The I
created local/html/Elements/EditCustomFieldJSON_Encoded_Resource_Field
and local/html/Elements/ShowCustomFieldJSON_Encoded_Resource_Field

Which do what I need them to - pretty print the JSON so a human can read
it and
edit it if necessary.

But RT thinks this custom field type allows multiple entries per field,
and so
pukes all over the pretty-printed JSON.

When I use a straight “Fill in one text area” RT is ok with the JSON,
but the
JSON is not pretty printed.

In that case, you could use Fill in one text area for editing and just
override display using the callbacks in ShowCustomField based on the
CF name.

Otherwise, look into the MaxValues setting.

How do I associate my new custom field Type “JSON_Encoded_Resource_Field”
with the “Fill in one text area” type. Is that a key value pair in the
CustomField_Local override?

Len.

-kevin


RT Training - Boston, September 9-10
Training — Best Practical Solutions

lenjaffe@jaffesystems.com 614-404-4214 @lenjaffe
Information Technology Smoke Jumper, Host of Columbus Code Jam
http://www.meetup.com/techlifecolumbus/
www.lenjaffe.com http://www.theycomewithcheese.com
Advent Planet http://www.lenjaffe.com/AdventPlanet/ - An Aggregation of
Online Advent Calendars.

How do I associate my new custom field Type “JSON_Encoded_Resource_Field” with
the “Fill in one text area” type. Is that a key value pair in the
CustomField_Local override?

Please note, I wasn’t suggesting that you use a custom type if you go
the “only override display” route. You use the ShowComponentName
callback in Elements/ShowCustomFields to say “For these CFs, use
ShowCustomField_JSON_Encoded_Resource_Field” and then editing just
works as a normal text box.

Alternately, again, ensure your MaxValues is set properly for your
custom CF type.

-kevin

How do I associate my new custom field Type
“JSON_Encoded_Resource_Field” with
the “Fill in one text area” type. Is that a key value pair in the
CustomField_Local override?

Please note, I wasn’t suggesting that you use a custom type if you go
the “only override display” route. You use the ShowComponentName
callback in Elements/ShowCustomFields to say “For these CFs, use
ShowCustomField_JSON_Encoded_Resource_Field” and then editing just
works as a normal text box.

OK. BUT… I think at some point I got an erro fo rnot having an Edit file
to go along with Show in the /Elements dir.
I’ll try it out again later today.

Alternately, again, ensure your MaxValues is set properly for your
custom CF type.

Can I do that in the CustomField_Local file or do I have to specifically
manipulate the database?

Len.

-kevin


RT Training - Boston, September 9-10
Training — Best Practical Solutions

lenjaffe@jaffesystems.com 614-404-4214 @lenjaffe
Information Technology Smoke Jumper, Host of Columbus Code Jam
http://www.meetup.com/techlifecolumbus/
www.lenjaffe.com http://www.theycomewithcheese.com
Advent Planet http://www.lenjaffe.com/AdventPlanet/ - An Aggregation of
Online Advent Calendars.