The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

detach(detachRequest) At this time, only a basic reference is supported, Contact reference is not supported yet.

    As an example, to attach a file to an expenseReport, you would do the
    following:

        sub nsRecRef {
            my ($rectype, $id) = @_;
            return  { type => $rectype, internalId => $id };
        }
 
        my $attachRequest = {
            attachTo        => nsRecRef('expenseReport', $erId),
            attachedRecord  => nsRecRef('file',          $fid)
        };
        $ns->attach($attachRequest) or nsfatal 'error attaching';

        The detach operation is coded exactly the same.

  errorResults
    The errorResults method is populated when a request returns an erroneous
    response from NetSuite. These errors can occur at anytime and with any
    operation. Always assume your operations will fail, and build your code
    accordingly.

    The hash reference that is returned looks like this:

        {
            'message' => 'You have entered an invalid email address or account
    number. Please try again.',
            'code' => 'INVALID_LOGIN_CREDENTIALS'
        };

    If there is something FUNDAMENTALLY wrong with your request (like you
    have included an invalid field), your errorResults may look like this:

        {
            'faultcode' => 'soapenv:Server.userException',
            'detailDetail' => 'partners-java002.svale.netledger.com',
            'faultstring' => 'com.netledger.common.schemabean.NLSchemaBeanException:
    <<somefield>> not found on {urn:relationships_2_6.lists.webservices.netsuite.com}Customer'
        };

    Thus, a typical error-prepared script might look like this:

        $ns->login or die "Can't connect to NetSuite!\n";
    
        if ($ns->search('customer', $query)) {
            for my $record (@{ $ns->searchResults->{recordList} }) {
                if ($ns->get('customer', $record->{recordInternalId})) {
                    print Dumper($ns->getResults);
                }
                else {
                    # If an error is encountered while running through
                    # a list, print a notice and break the loop
                    print "An error occured!\n";
                    last;
                }
            }
        }
        else {
        
            # I really want to know why my search would fail
            # lets output the error and message
            my $message = $ns->errorResults->{message};
            my $code = $ns->errorResults->{code};
        
            print "Unable to perform search!\n";
            print "($code): $message\n";
        
        }
    
        $ns->logout; # no error handling here, if this fails, oh well.

    For a complete listing of errors and associated messages, consult the
    SuiteTalk (Web Services) Records Guide.

    <http://www.netsuite.com/portal/developers/resources/suitetalk-documenta
    tion.shtml>

AUTHOR Fred Moyer, fred@redhotpenguin.com

LICENCE AND COPYRIGHT Copyright 2013, iParadigms LLC.

    Original Netsuite module copyright (c) 2008, Jonathan Lloyd. All rights
    reserved.

    This module is free software; you can redistribute it and/or modify it
    under the same terms as Perl itself. See perlartistic.

ACKNOWLEDGEMENTS Initial content shamelessly stolen from https://github.com/gitpan/NetSuite

    Thanks to iParadigms LLC for sponsoring the reboot of this module.