今天突然有个想法,在 NetSuite 中如何实现一个 entity 同时是客户和供应商。是否有快捷的功能,使之相互转化?简单搜索了下 google,很快就找到了对应的资料。
首先是看到了 Marty Zigman 的文章http://blog.prolecto.com/2015/08/29/convert-a-netsuite-lead-to-a-vendor/。这个文章是介绍如何将 NetSuite 中的 Lead 转换为 Vendor 的,功能有些类似,中间提到了 Other Relationship 的功能。同时指出没有 OOTB 的方法,直接将 Lead 转换为 Vendor。但这个 Other Relationship 也基本能满足我的想法了。
我们看看 Other Relationship 的使用方法。
Other Relationship 的功能在客户/供应商的 Relationships 子标签下。
只有在编辑模式下,才可以点击+图标来新建其它关系。
由于当前我的记录是 Customer,所以这里只有 Partner/Other Name/Vendor 可选。如果当前记录是 Vendor,则有 Partner/Other Name/ Customer 可选。 但是如果已经有了某关系,如当前为 Vendor,已经有了 Customer 的关系,则只能再创建 Partner/Other Name 关系。
关于 Other Name 的介绍,在 HELP 里也可以找到。 这个 Other Name 既不是 Vendors 也不是Customers/Employees 等。只是为了让我们记录一些人员或公司。举例就是比如你的公司捐款给某慈善组织,你就可以创建一个 Other Name 的记录。
回到 Marty Zigman 的文章,如果有需要由 Customer 转换为 Vendor 的话,可以认真看相应的代码。为防止链接失效,这里把他的代码 COPY 下来。
function Convert_Lead_To_Vendor() {
var recid = nlapiGetRecordId();
//only act if we get a record ID
if (!recid) return;
//ask the user if they really want to do this
if (!confirm("Are you sure you want to convert this lead to a vendor?"))return;
// hitting this url will add the entity as a vendor
var url = '/app/common/entity/company.nl?e=T&target=s_relation:otherrelationships&label=Other+Relationships&fromtype=custjob&id=' + recid + '&totype=vendor';
nlapiRequestURL(url);
// now try to load the vendor record to confirm we did the work
var worked = false;
try{
nlapiLoadRecord('vendor', recid);
worked = true;
}catch(e){
worked = false;
}
//if it worked, redirect the user to the entity vendor view
if (worked){
var url = nlapiResolveURL('RECORD', 'lead', recid) + '&custparam_flag_lead='+CONST_CUSTSTATUS_APPROVED + '&custparam_next_entity=vendor';
document.location = url;
return;
}
}