我正在尝试使用webservices在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
的自定义字段
做了一些搜索后,我发现:
从这个链接我知道我需要使用CustomFieldRef
,我只是不确定它是如何实现的。
答案 0 :(得分:2)
我找到了一种方法:
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