2016-03-02 79 views
0

我想在NetSuite中创建一个需要客户一些历史信息的脚本。事实上,我需要的信息是知道用户是否购买了物品。 为此,我需要以某种方式访问​​此客户的历史记录。如何使用NetSuite中的脚本检查特定客户的历史信息?

Pablo。

+0

如果您恰当地使用在客户记录_Stage_字段,然后,有一个客户的任何记录_Customer_的_Stage_应该购买了一些东西。如果你没有这样使用Stage字段,那么这看起来不像是一个难以建立的搜索。 您对“用户购买物品”的定义是什么?是否为此客户提供销售订单?发票?现金出售? – erictgrubaugh

回答

0

尝试加入这个功能并通过客户的internalID和项目internalID

function hasPurchasedBefore(customerInternalID, itemInternalID){ 
    var results = []; 
    var filters = []; 
    var columns = []; 

    filters.push(new nlobjSearchFilter('internalidnumber', 'customermain', 'equalto', [customerInternalID])) 
    filters.push(new nlobjSearchFilter('anylineitem', null, 'anyof', [itemInternalID])); 
    filters.push(new nlobjSearchFilter('type', null, 'anyof', ['CustInvc'])); 
    columns.push(new nlobjSearchColumn('internalid', null, 'GROUP')); 

    results = nlapiSearchRecord('transaction', null, filters, columns); 

    if (results && results.length){ 
     return true; 
    } 
    return false; 
} 

例子:

var record = nlapiLoadRecord(nlapiGetRecordType(),nlapiGetRecordId()); 
var customerInternalID = record.getFieldValue('entity'); 
var itemInternalID = record.getLineItemValue('item', 'item', 1); //Gets line 1 item Internal ID 

if(hasPurchasedBefore(customerInternalID, itemInternalID)) { 
    //Has bought something before 
} 
+0

嗨阿道夫感谢的脚本,它没有实际工作。它始终得到客户从未购买过物品。顺便说一下,我可以从哪里获得所有要搜索的实体?像客户,销售,交易等?再次感谢好友 – Pablo

+0

以下是类型,您可以将它们添加到您的过滤器中:http://blog.prolecto.com/2014/01/03/netsuite-searchfilter-internal-transaction-type-codes/ –

+0

谢谢阿道夫..我会检查并让你知道。 – Pablo

0

您可以使用已保存的搜索nlapiLoadSearchnlapiCreateSearch代替invoices,由客户过滤,还可以报告发票项目(或只是特定项目)。使用nlapiCreateSearch可能会非常棘手使用,所以我建议建立使用UI保存的搜索,然后使用nlapiLoadSeach(type, id)

这会给你发票/购买了你的产品的客户的数组加载它。

相关问题