[rt-users] Not saving custom fields in RTFM upon Article creation
Jeff Platter
jplatter at vortexit.net
Tue Jun 12 18:18:58 EDT 2007
So I think I figured out what was going on. I have fixed the problem for my
RTFM situation but I need to know if what I did was the right thing or not.
So if one of the developers would like to look this over that would be
fantastic, and let me know if I broke anything else or not.
I found the problem to be that the format for
ProcessObjectCustomFieldUpdates in /rt3/ lib/RT/Interface/Web.pm. The format
for the custom object that it is expecting is: # format: Object-<object
class>-<object id>-CustomField-<CF id>-<commands>
However when you load /rt3/share/html/RTFM/Article/Edit.html for the first
time to create an article there is no initial object id. So the field end up
being Object-<object class>--CustomField-<CF id>-<commands> with a missing
object id section.
When ProcessObjectCustomFieldUpdates runs the first loop:
foreach my $arg ( keys %$ARGSRef ) {
# format: Object-<object class>-<object id>-CustomField-<CF
id>-<commands>
next unless $arg =~
/^Object-([\w:]+)-(\d*)-CustomField-(\d+)-(.*)$/;
# For each of those objects, find out what custom fields we want to
work with.
$custom_fields_to_mod{ $1 }{ $2 || 0 }{ $3 }{ $4 } = $ARGSRef->{
$arg };
}
It ends up setting the ID field to 0 cause it doesn't exist. Then when it
loops through the class and id's later and tries to get the $Object:
$Object->Load( $id ) unless ($Object->id || 0) == $id;
It resets the object id to the wrong thing because the article has already
been created by this point and it has an id but the custom fields don't
associate with that object id
I don't know if I'm making any sense with this anymore.
Here is what I did to fix the issue:
foreach my $arg ( keys %$ARGSRef ) {
# format: Object-<object class>-<object id>-CustomField-<CF
id>-<commands>
next unless $arg =~
/^Object-([\w:]+)-(\d*)-CustomField-(\d+)-(.*)$/;
my $Object = $args{'Object'} if exists $args{'Object'};
my $id = $Object->id || 0;
# For each of those objects, find out what custom fields we want to
work with.
$custom_fields_to_mod{ $1 }{ $2 || $id }{ $3 }{ $4 } = $ARGSRef->{
$arg };
}
I changed the first loop to pull the object if it was passed in and set the
id to the object->id or to 0. So it should default back to what it was doing
before if no object is currently passed in.
Someone please take the time to read this and let me know if what I did is
good or not. If ne1 else is having this issue and needs a patch file I can
create one and send / post it somewhere, just lmk.
Thanks for all the help this list has been so far.
-Jeff
From: rt-users-bounces at lists.bestpractical.com
[mailto:rt-users-bounces at lists.bestpractical.com] On Behalf Of Jeff Platter
Sent: Tuesday, June 12, 2007 4:36 PM
To: rt-users at lists.bestpractical.com
Subject: [FILTER] [rt-users] Not saving custom fields in RTFM upon Article
creation
I'm using RTFM 2.2.0RC5 with RT 3.6.3. I have created a custom field for the
body of the article. I have setup all permissions on the custom field and
added it to the class that I want it in. When creating a new article it
doesn't save the value of the custom field that I have. I have to go back in
to the article and modify the field and then it saves ok.
Is this a bug or is there a setting that I'm missing?
Thanks,
-Jeff
--
This message has been scanned for viruses and
dangerous content by <http://www.mailscanner.info/> MailScanner, and is
believed to be clean.
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20070612/97b8f1dd/attachment.htm>
More information about the rt-users
mailing list