我正在尝试使用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,但我不确定该如何实现。

最佳答案

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

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()


您必须对要使用的字段使用引用类型:https://system.na1.netsuite.com/app/help/helpcenter.nl?fid=section_n3458179.html

关于python - Python-如何使用NetSuite Web服务设置自定义字段,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50823359/

10-13 02:36