Hello everyone,
I need a bit of help here. I am trying to write a client script that runs on save record on a Sales Order that will look through all of the line items to see if any have been marked true(check box field) for a custom field called "Is Virtual." If any of them have been checked, then run the rest of my script. The rest of the script works fine without this initial If statement so this is the last piece to the puzzle. Thanks!
function saverecord(){
var LineItemCount = nlapiGetLineItemCount('item');
nlapiLogExecution('debug', 'Line Item Count', LineItemCount);
var i = 1;
for(i; i<= LineItemCount; i++) {
var IsVirtual = nlapiGetLineItemValue('item', 'custcol_is_virtual', i);
}
if(IsVirtual = 'T'){
var Company = nlapiGetFieldValue('entity');
nlapiLogExecution('debug', 'Company', Company);
var ContractAdminID = 2;
var Filters = new Array();
Filters[0] = new nlobjSearchFilter('company', null, 'anyof', Company);
Filters[1] = new nlobjSearchFilter('category', null, 'anyof', ContractAdminID);
var Columns = new Array();
Columns[0] = new nlobjSearchColumn('internalid');
var Results = nlapiSearchRecord('contact', null,Filters,Columns);
nlapiLogExecution('debug', 'Search Results', Results);
if (Results != null && Results != '') {
ContractAdminRecord = Results[0];
ContractAdminFullName = ContractAdminRecord.getValue('internalid');
nlapiLogExecution('debug', 'Contract Admin Full Name', ContractAdminFullName);
nlapiSetFieldValue('custbody_contract_admin', ContractAdminFullName);
return true;
}
if (Results == null || Results == '') {
var URL = nlapiResolveURL('RECORD', 'customer', Company, 'VIEW');
alert('Please designate a contract administrator for this customer before saving the Sales Order.');
window.open(URL);
return false;
}
}
return true;
}
For some reason my debug stopped working once I added this to the code. Does anyone else have trouble with debug mode randomly stopping from working?