[Rt-devel] How to Update CustomField values

Kevin Falcone falcone at bestpractical.com
Fri Nov 12 12:39:46 EST 2010


On Fri, Nov 12, 2010 at 05:42:52PM +0100, Simone Sanna wrote:
> Hello List,
> I need to update the values of a given customfield, I mean be able
> to change anything in Name, Description,  SortOrder and Category,
> based on the customfield value Id associated.
> I have found how to show, add and delete, that I need too, but in
> CustomField_Overlay.pm, there is nothing called *Update* and  I
> couldn't find anything clear that could let me update a customfield,
> I mean change its values keeping the same Id.

I bet there is code in share/html/Admin/CustomFields/Modify.html which
handles that and can show you what to do.

-kevin

> Could someone show me how to do that or refer me to some examples?
> 
> Many thanks in advance.
> 
> Kind regards,
> Simone
> 
> 
> 
> 
> #!/usr/bin/perl
> use lib qw(/opt/rt3/local/lib /opt/rt3/lib);
> use RT;
> use RT::Date;
> use RT::Queue;
> use RT::Tickets;
> use RT::Action::RecordComment;
> use RT::Transaction;
> use RT::CustomFields;
> 
> 
> RT::LoadConfig();
> RT::Init();
> 
> 
> new RT::Ticket($RT::SystemUser);
> my $cf_obj = RT::CustomField->new($RT::SystemUser);
> my $cf_name = "Severity";
> 
> 
> $cf_obj->LoadByName( Name => $cf_name );
> 
> print ("Loaded \$cf_obj->Name = ". $cf_obj->Name() . " " .
> $cf_obj->Id() . "\n");
> 
> ### This adds a new value
> $cf_obj->AddValue(Name=> 'Critical', Description=> 'Critical',
> SortOrder => '0');
> 
> ### This updates the customfield value for a given id
> ???????
> 
> ###This deletes a customfield value for a given id
> $cf_obj->DeleteValue(##);
> 
> ###This shows how to get the defined values of the customfield,
> along with IDs, and sort orders.
> $values = $cf_obj->Values();
> while(my $value = $values->Next){
> print $value->Name() . "--" . $value->Id() . "--" .
> $value->SortOrder() . "\n";
> }
> 
> -- 
> Simone Sanna
> Spectrum&  IT Policies System Administrator
> TINET SPA
> Località Sa Illetta S.S.195 Km.2,300
> 09122 Cagliari (ITALY)
> Ph. +39 0704600728
> E-mail: simone.sanna at tinet.net
> 
> _______________________________________________
> List info: http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <http://lists.bestpractical.com/pipermail/rt-devel/attachments/20101112/bcbbd7f2/attachment.pgp>


More information about the rt-devel mailing list