Python - 如何使用 NetSuite 网络服务设置自定义字段
Python - How to Set Custom Fields using NetSuite 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
的自定义字段
经过一番搜索后,我发现:
从这个 link 我知道我将需要使用 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()
您必须为正在使用的字段使用 Ref 类型:https://system.na1.netsuite.com/app/help/helpcenter.nl?fid=section_n3458179.html
我正在尝试能够使用网络服务在 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
的自定义字段
经过一番搜索后,我发现:
从这个 link 我知道我将需要使用 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()
您必须为正在使用的字段使用 Ref 类型:https://system.na1.netsuite.com/app/help/helpcenter.nl?fid=section_n3458179.html