Salman Afzal
12/05/2019, 8:54 AM/**
*@NApiVersion 2.x
*@NScriptType ClientScript
*/
define(['N/record', 'N/ui/dialog'], function (record, dialog) {
function BillEdit(bill_id) {
var objRecord2 = record.load({
type: record.Type.VENDOR_BILL,
id: bill_id,
isDynamic: true,
});
var bill_applied = objRecord2.getValue({
fieldId: 'custbody49'
});
if (!bill_applied) {
objRecord2.setValue({
fieldId: 'custbody49',
value: true,
ignoreFieldChange: true
});
dialog.alert({
title: 'Alert',
message: 'Before Save'
});
var recordId = objRecord2.save({
enableSourcing: true,
ignoreMandatoryFields: true
});
dialog.alert({
title: 'Alert',
message: 'Saving the record is mandatory' + recordId
});
}
}
function fieldChanged(context) {
var currentRecord = context.currentRecord;
var cid = currentRecord.id;
var objRecord = record.load({
type: record.Type.ITEM_RECEIPT,
id: cid,
isDynamic: true,
});
var fieldname = context.fieldId;
if (fieldname == 'landedcostsourcetran2') {
var Sourcetran1 = objRecord.getValue({
fieldId: 'landedcostsourcetran2'
});
BillEdit(Sourcetran1);
}
if (fieldname == 'landedcostsourcetran3') {
var Sourcetran2 = objRecord.getValue({
fieldId: 'landedcostsourcetran3'
});
BillEdit(Sourcetran2);
}
if (fieldname == 'landedcostsourcetran12') {
var Sourcetran3 = objRecord.getValue({
fieldId: 'landedcostsourcetran12'
});
BillEdit(Sourcetran3);
}
if (fieldname == 'landedcostsourcetran13') {
var Sourcetran4 = objRecord.getValue({
fieldId: 'landedcostsourcetran13'
});
BillEdit(Sourcetran4);
}
if (fieldname == 'landedcostsourcetran19') {
var Sourcetran5 = objRecord.getValue({
fieldId: 'landedcostsourcetran19'
});
BillEdit(Sourcetran5);
}
if (fieldname == 'landedcostsourcetran20') {
var Sourcetran6 = objRecord.getValue({
fieldId: 'landedcostsourcetran20'
});
BillEdit(Sourcetran6);
}
}
return {
fieldChanged: fieldChanged
}
});