我正在尝试使用地址记录和主要联系人记录创建新的客户记录。此代码创建客户记录和地址记录,但不创建主要联系人记录。有谁知道如何创建主要联系人记录?
var customerrecord=nlapiCreateRecord('customer');
customerrecord.setFieldValue('customform','3'); // form is Customer Form
customerrecord.setFieldValue('isperson', 'F'); // true or false
customerrecord.setFieldValue('companyname', datain.companyname);
customerrecord.setFieldValue('entitystatus', '13');
customerrecord.setFieldValue('category', '8');
customerrecord.setFieldValue('salesrep', '1606'); // employee record
customerrecord.setFieldValue('email', datain.email );
customerrecord.setFieldValue('phone', datain.phone);
customerrecord.setFieldValue('fax', datain.fax);
customerrecord.setLineItemValue('addressbook','addressee',1,datain.companyname);
customerrecord.setLineItemValue('addressbook','attention',1,datain.attention);
customerrecord.setLineItemValue('addressbook','addr1',1,datain.addr1);
customerrecord.setLineItemValue('addressbook','addr2',1,datain.addr2);
customerrecord.setLineItemValue('addressbook','city',1,datain.city);
customerrecord.setLineItemValue('addressbook','state',1,datain.state);
customerrecord.setLineItemValue('addressbook','zip',1,datain.zip);
customerrecord.setLineItemValue('addressbook','phone',1,datain.phone);
customerrecord.setLineItemValue('addressbook','label',1,datain.addr1);
customerrecord.selectNewLineItem('contact');
customerrecord.setCurrentLineItemValue('contact','contactrole','-10');
customerrecord.setCurrentLineItemValue('contact','firstname',datain.attention);
customerrecord.setCurrentLineItemValue('contact','email',datain.email);
customerrecord.setCurrentLineItemValue('contact','phone',datain.phone);
customerrecord.commitLineItem('contact');
var customerid = nlapiSubmitRecord(customerrecord, false, true);
return "customer record created: " + datain.companyname;