Hey guys, Is there a tool that can indicate all o...
# suitescript
p
Hey guys, Is there a tool that can indicate all of the required fields of a record? (like a chrome ext) I know you can view the #NetsuiteRecordBrowser for this, was just wondering... If there isn’t such a thing, I would love to start an opensource project for this ☺️
d
I think this should work:
Copy code
function getMandatoryFields() {
    // Assumes has loaded N/record to browser console
	
    var rec = record.load({type : nlapiGetRecordType(), id : nlapiGetRecordId(), isDynamic : true });
	var fieldIds = rec.getFields().filter(x => !x.startsWith('_')).sort();
    var fieldObjects = fieldIds.map(x => rec.getField(x));

	var requiredFields = fieldObjects.filter(x => x && x.isMandatory);

	return requiredFields.map(x => x.id);
}
p
nice, i’ll try it out SS1 right?
d
no, that is mainly SS2 I just used those 2 nlapi methods from SS1 since they're already on the browser console
p
got it thanks