View on
Fred Moyer > WebService-NetSuite-0.05 > README


Annotate this POD


New  1
Open  0
View/Report Bugs

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

        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.

    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

    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' => '',
            'faultstring' => 'com.netledger.common.schemabean.NLSchemaBeanException:
    <<somefield>> not found on {}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";
        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.


AUTHOR Fred Moyer,

LICENCE AND COPYRIGHT Copyright 2013, iParadigms LLC.

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

    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

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