How to get all custom fields of a particular record type in Netsuite using RESTlet?

徘徊边缘 提交于 2019-12-12 04:10:02

问题


I can create a customer, lead, contact using RESTlet. But my code is used by someone who created custom fields with required option. When I try to create a customer, I am getting error by custom required fields.

I want to pass the data for custom required fields too. How to know the all custom fields categorized by required and none required using RESTlet?


回答1:


You can use

var record = nlapiCreateRecord(RECORD_TYPE);
var fields = record.getAllFields();
var requiredFields = [];
fields.forEach(function(fieldName){
 var field = record.getField(fieldName);
 //I am not very sure, its true or T but, below code will work
 if(field.mandatory === true || field.mandatory === 'T'){
   requiredFields.push(field.getName()) //getLabel() for UI label, as getName returns id;
 }
});

//requiredFields array is your need.




回答2:


Actually in this situation I take one of two approaches (or combine them):

The first is to just ignore mandatory fields. You view your code's job is to get information into Netsuite and users will have to be responsible for future updates. You do this by telling Netsuite to ignore mandatory fields when your code saves them:

nlapiSubmitRecord(nlobjRecord, doSourcing, ignoreMandatoryFields); //doSourcing and ignoreMandatoryFields are booleans

or I add a text area parameter to the restlet where the person configuring the restlet has to enter a list of extra fields you want to do something with (e.g. display in a dialog and make required)



来源:https://stackoverflow.com/questions/35178870/how-to-get-all-custom-fields-of-a-particular-record-type-in-netsuite-using-restl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!