Netsuite PHP Toolkit Directory Global Scope Problem

The latest version of the PHP Toolkit for Netsuite web-services (2010_2 as of this writing) and all previous versions (as far as I know) assume that the $endpoint string and $myDirectory array are declared in global scope.

However, if in your code you load the tool kit inside of a class method or function, or you utilize PHP’s autoload function, it’s quite likely you’ll be seeing a frustrating error like this:


ComplexType reference was not found in directory. ComplexTypeName = Record

Here’s the good news: The solution to this problem is simple.  Just declare each variable to be global before the value is set.  For example, here’s what the first part of directory_v2010.2.php should look like:

global $endpoint;

$endpoint = "2010_2";

global $myDirectory;

$myDirectory = array ( ...
This entry was posted in Netsuite PHPToolkit and tagged , , . Bookmark the permalink.

5 Responses to Netsuite PHP Toolkit Directory Global Scope Problem

  1. Luiz says:

    I had to add global $myDirectory to getNameSpace. However, I still got that exception thrown; because $myDirectory is NULL when it runs through foreach in that function.

    Have you had any luck getting pass that?

    • donaldvr says:

      @Luiz Sorry, we haven’t had that problem and we don’t have global $myDirectory in our getNameSpace function. What version of the PHPToolkit are you using?

    • Laurent Camarasa says:

      I had the same issue, here is what I changed in PHPToolkit.php to solve it :

      require_once ‘directory_v2011.2.php’;

      global $myDirectory;
      global $endpoint;

      Change this to :

      global $myDirectory;
      global $endpoint;

      require_once ‘directory_v2011.2.php’;

      Seems to have fixe the issue for me ! Hope it works for you too…

      Laurent

  2. Jeff says:

    Thanks for posting this! Really saved me some time.

  3. Pingback: Joe Motacek » Blog Archive » Joomla 2.5 Extension Development – Creating a Plug-In

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>