NetSuite Error: CustomFieldRef is an abstract type and cannot be instantiated

NetSuite Error: CustomFieldRef is an abstract type and cannot be instantiated

我正在研究 NetSuite WSDL。我被过去两天的这个错误困住了。我已经在互联网上搜索但找不到解决方案。

我尝试使用 Python 在 NetSuite 中添加 custom field,但出现错误

zeep.exceptions.Fault: org.xml.sax.SAXException: {urn:core_2017_1.platform.webservices.netsuite.com}CustomFieldRef is an abstract type and cannot be instantiated

如有任何帮助,我们将不胜感激。提前致谢。

该错误几乎是不言自明的,但除非您已经理解它,否则没有帮助。

如果您想 edit/create 自定义字段,您必须实例化正确的类型。

例如在 Java

StringCustomFieldRef strCF = new StringCustomFieldRef();
strCF.setInternalId(cfNSKey);

您可以在 Netsuite docs

中获取类型列表

我使用 SelectCustomFieldRef 而不是 CustomFieldRef 解决了这个问题。即

new_record['companyName']= 'test_clinic1'
new_record['firstName']= 'test_clinic_first_name1'
new_record['altName']= 'test_clinic1'
new_record['lastName']='test_last__clinic_name2'
record = RecordRef(internalId=1, type='subsidiary')
new_record['subsidiary'] = record

customField= SelectCustomFieldRef()
customField.internalId='285'
customField.scriptId='custentity_profile_type'
customField.value={
                'name': 'Clinic',
                'internalId': '2',
                'externalId': None,
                'typeId': '31'
            }

new_record['customFieldList']=CustomFieldList(customField)