[freeside] Quick Example of Cust_main updates
ivan at 420.am
ivan at 420.am
Tue Nov 11 16:38:45 PST 2003
The field name is comments, with an s at the end. See the FS::cust_main
manpage.
--
_ivan
On Tue, Nov 11, 2003 at 07:23:45PM -0800, Lucas Heuman wrote:
> Ok, Here was my unsuccessful attempt, code worked great for using other
> methods like credit but replace isn't working.
>
> -----------
>
> use FS::UID qw(adminsuidsetup);
> use FS::Record qw(qsearchs);
> use FS::cust_main;
>
> adminsuidsetup 'lucas';
>
> $acct = 1003;
>
> my $old = qsearchs('cust_main',{'custnum' => $acct })
> or die "Can't lucking do this!";
>
> if ($old)
> {
> $dacomments = $old->comment;
>
> $dacomments .= "owes Aug & Sept $35.90 BMC 9/27";
>
> my $new = new FS::cust_main({ $old->hash });
>
> #print "\n\nMESA REPLACESA $dacomments\n\n";
> $new->comment($dacomments);
>
> $o=$old->comment();
> $n=$new->comment();
> print "old: $o\n";
> print "new: $n\n";
>
> my $error = $new->replace($old);
>
> if ($error)
> { print "$acct $error\n"; }
> }
>
>
>
>
>
>
> [ Wrote 38 lines ]
>
> freeside at Freeside:/home/lucas/freeside$ ./thed
> old:
> new: owes Aug & Sept .90 BMC 9/27
> [warning][FS::Record] FS::cust_main=HASH(0x82ac138) -> replace
> FS::cust_main=HASH(0x89b048c): records identical at ./thed line 34
>
>
>
> -----Original Message-----
> From: ivan at 420.am [mailto:ivan at 420.am]
> Sent: Monday, November 10, 2003 7:53 AM
> To: ivan-freeside at sisd.com
> Subject: Re: [freeside] Quick Example of Cust_main updates
>
>
> 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
>
--
_ivan
More information about the freeside-users
mailing list