[freeside] Quick Example of Cust_main updates
ivan at 420.am
ivan at 420.am
Mon Nov 10 07:53:26 PST 2003
On Mon, Nov 10, 2003 at 10:20:12AM -0800, Lucas Heuman wrote:
> Hello, I'm new to perl and this is a perl related questions regarding
> freeside-1.4.1 perl API.
>
> I wrote a script that uses customer numbers to make changes to Cust_main. I
> don't understand how to use perl to referance a customer number then modify
> the comment field (or any other field) then save the change. Could some one
> please give a example.
use FS::UID qw(adminsuidsetup);
use FS::Record qw(qsearchs);
use FS::cust_main;
adminsuidsetup 'freeside-username';
my $old = qsearchs( 'cust_main', { 'custnum' => $custnum } )
or die "can't find customer number $custnum";
my $new = new FS::cust_main( { $old->hash } );
$new->comment( 'modified comment' );
my $error = $new->replace($old);
if ( $error ) {
#handle error
} else {
#update successful
}
--
_ivan
More information about the freeside-users
mailing list