Netsuite-使用php工具包获取自定义记录

Netsuite-使用php工具包获取自定义记录,php,record,toolkit,netsuite,Php,Record,Toolkit,Netsuite,我收到了一个要完成的项目,客户要求在每个客户的网站上显示客户记录中的一个字段。我们在登录时与Netsuite集成,并将它们的数据保存在我们的数据库中,这样我们就不必一直访问Netsuite(非常慢) 登录时,我们访问Netsuite以执行SearchMultiSelectCustomField并查找客户的公司,然后执行CustomRecordSearchBasic并使用其公司ID获取他们有权访问的项目列表 我们在每个项目上循环,然后在它们的自定义字段上循环。其中一个字段的typeId为-10,这

我收到了一个要完成的项目,客户要求在每个客户的网站上显示客户记录中的一个字段。我们在登录时与Netsuite集成,并将它们的数据保存在我们的数据库中,这样我们就不必一直访问Netsuite(非常慢)

登录时,我们访问Netsuite以执行SearchMultiSelectCustomField并查找客户的公司,然后执行CustomRecordSearchBasic并使用其公司ID获取他们有权访问的项目列表

我们在每个项目上循环,然后在它们的自定义字段上循环。其中一个字段的typeId为-10,这意味着我们执行ItemSearchBasic以获取该项的记录和该项的自定义字段,并保存该项的内部ID

在这个循环的末尾,我们有一个公司链接到的项目ID数组。我们还有公司ID(客户记录\项目\客户)和项目ID(客户记录\项目\客户列表)

我需要对自定义记录执行get请求,以检查该客户是否已获得该项目的批准

customrecord的ID为“customrecord\u custitem”,内部ID为“1”。 该记录有3个字段(尽管客户的Netsuite记录页面仅显示2个字段):

custrecord\u lookup\u item-这是项目记录代码(上面的custrecord\u nn\u item\u customer\u列表) custrecord\u custitem\u代码是我需要的代码

我的问题(毕竟)是,有没有人可以举一些例子,或者告诉我如何访问附加到客户的customrecord的正确方向?我认为已经提供了所有必要的信息,但我以前从未使用过Netsuite或PHP工具包

$this->depends('netsuite');
$this->netsuite->start();

// get the "customer" (aka company) that the user's contact record belongs to
$companySearch = $this->netsuite->complexObject('SearchMultiSelectCustomField')
    ->setFields(array(
        'searchValue' => new nsListOrRecordRef(array('internalId' => $companyId)),
        'internalId' => 'custrecord_nn_item_customer',
        'operator' => 'anyOf'
    ));

// Fetch items that the user's company has access to
$search = $this->netsuite->complexObject('CustomRecordSearchBasic')
    ->setFields(array(
        'recType' => new nsCustomRecordRef(array(
            'internalId' => 260,
            'type' => 'customRecord')
        ),
        'customFieldList' => array($companySearch)
    ));
    $response = $this->netsuite->client->search($search);



    // loop over the items
    foreach($this->netsuite->complexToSimple($response->recordList) as $record){
        //var_dump($record);
        $processor = null;
        $this_item = '';
        $this_person = '';
        // foreach custom field (all the fields we're interested in, common name etc. are custom)
        foreach($record['customFieldList']['customField'] as $customField){
            $processor = $customField['value'];
            $id = $processor['internalId'];
            $typeId = $processor['typeId'];

            if($customField['internalId']=='custrecord_nn_item_customer'){
                $this_person = $id;
            }elseif($customField['internalId']=='custrecord_nn_item_customer_list'){
                $this_item = $id;
            }

            // a typeId of -10 = an Inventory Item
            if($typeId == -10){


                // do an ItemSearchBasic to fetch the item with it's custom fields
                $itemSearch = $this->netsuite->complexObject('ItemSearchBasic')
                    ->setFields(array(
                        'internalId' => array(
                            'operator' => 'anyOf',
                            'searchValue' => array('type' => 'inventoryItem', 'internalId' => $id)
                        )
                    ));

                $itemSearch = $this->netsuite->client->search($itemSearch);

                // foreach custom item field
                if($v=@$this->netsuite->complexToSimple($itemSearch->recordList)){
                    foreach($v as $itemRecord){
                        //var_dump($itemRecord);
                        $item = array('id' => $itemRecord['internalId']);

                        $items[] = $item;
                    }
                }
            }
        }
    }

在foreach循环中,我需要获取公司ID的customrecord字段和项目ID的当前迭代。

使用所需的结果列设置保存的搜索。不要担心按客户筛选

从代码中调用搜索,并动态筛选当前客户


您的代码应该大约有5-10行长才能完成,而且应该非常快。

使用所需的结果列设置保存的搜索。不要担心按客户筛选

从代码中调用搜索,并动态筛选当前客户


要完成这项工作,您的代码应该有5-10行,而且应该非常快。

如果您共享一些代码,您更有可能获得实质性的帮助。不用担心,我已经添加了这部分代码。我不熟悉net suite,因此我的建议是严格使用php。您可以使用var\u dump,或者打印r并查看其内部外观,例如,在out foreach循环中,您可以使用var\u dump($record);您还可以获取_class_方法($record),并查看是否存在任何明显的getter或setter。如果您共享一些代码,您更有可能获得实质性帮助。不用担心,已经添加了这部分代码。我不熟悉net suite,因此我的建议是严格使用php。您可以使用var\u dump,或者打印r并查看其内部外观,例如,在out foreach循环中,您可以使用var\u dump($record);您还可以获取\u类\u方法($record),并查看是否存在任何明显的getter或setter。