2

我正在尝试使用 Web 服务在 NetSuite 中设置自定义字段。我正在使用的 WSDL 是:https ://webservices.netsuite.com/wsdl/v2017_2_0/netsuite.wsdl

目前我正在测试它来创建一个客户。这是我到目前为止所拥有的:

def add_customer():
  client = login_client()
  RecordRef = client.get_type('ns0:RecordRef')
  Customer = client.get_type('ns13:Customer')
  customer = Customer(
    companyName='TEST',
    subsidiary = RecordRef(internalId='5', type='subsidiary')
  )
  response = client.service.add(customer)
  print(response) 

add_customer()

这工作得很好,但现在我试图用 id 设置一个自定义字段custfield1 在做了一些搜索之后,我发现:

http://www.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2016_2/schema/other/customfieldlist.html?mode=package

从这个链接我知道我需要使用CustomFieldRef,我只是不确定它是如何实现的。

4

1 回答 1

3

我找到了一种方法来做到这一点:

def add_customer():
   client = login_client()
   RecordRef = client.get_type('ns0:RecordRef')
   StringCustomFieldRef = client.get_type('ns0:StringCustomFieldRef') #StringCustomFieldRef
   CustomFieldList = client.get_type('ns0:CustomFieldList') #To go from object to list

   #Cust field 1
   acctName = StringCustomFieldRef()
   acctName.internalID = '1569'
   acctName.scriptId = 'custentity_account_name'
   acctName.value = 'testData'

   #custField2
   acctID= StringCustomFieldRef()
   acctID.internalId= '1596'
   acctID.scriptId= 'custentity_sf_account_id'
   acctID.value = 'FIELD DATA'

   Customer = client.get_type('ns13:Customer')
   customer = Customer(
      companyName='TEST',
      entityId='TEST ID',
      subsidiary = RecordRef(internalId='5', type='subsidiary'),
      customFieldList = CustomFieldList([acctID,acctName]) #List of cust objects
   )
   response = client.service.add(customer)
   print(response)

add_customer()

您必须为正在使用的字段使用 Ref 类型:https ://system.na1.netsuite.com/app/help/helpcenter.nl?fid=section_n3458179.html

于 2018-06-12T19:15:51.603 回答