Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function createRecord(datain)
- {
- var err = new Object();
- // Validate if mandatory record type is set in the request
- if (!datain.employee_id) {
- err.status = "failed";
- err.message= "missing employee id";
- return err;
- } else if (!datain.employee_name) {
- err.status = "failed";
- err.message= "missing employee name";
- return err;
- }
- var record = nlapiCreateRecord('customrecord260');
- for (var fieldname in datain) {
- if (datain.hasOwnProperty(fieldname)) {
- if (fieldname != 'id') {
- var value = datain[fieldname];
- if (value && typeof value != 'object') { // ignore other type of parameters
- nlapiLogExecution('DEBUG', fieldname + ' = ' + value);
- record.setFieldValue(fieldname, value);
- }
- }
- }
- }
- var recordId = nlapiSubmitRecord(record);
- nlapiLogExecution('DEBUG','id='+recordId);
- var nlobj = nlapiLoadRecord('customrecord260',recordId);
- return nlobj;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement