This is my script `function customizeGlImpact(tran...
# suitescript
v
This is my script
function customizeGlImpact(transactionRecord, standardLines, customLines, book){
var recordType = transactionRecord.getRecordType();
var warrantyReplacement = transactionRecord.getFieldValue('custbody_warranty_replacement');
var status = transactionRecord.getFieldValue('shipstatus');
if(recordType === 'itemfulfillment' && status === 'C' && warrantyReplacement === 'T'){
var lineCount = standardLines.getCount();
for(var i = 0; i < lineCount; i++){
var currentLine = standardLines.getLine(i);
var glAccountID = currentLine.getAccountId();
var glEntityID = currentLine.getEntityId();
if(glAccountID && glAccountID !== null){
nlapiLogExecution('debug','entering line',i);
nlapiLogExecution('debug','glaccount',glAccountID);
if(glAccountID === 215){
var totalDebitAmount = parseFloat(currentLine.getDebitAmount()) || 0;
nlapiLogExecution('debug','totalDebitAmount',totalDebitAmount);
if(totalDebitAmount > 0 && totalDebitAmount !== null){
nlapiLogExecution('debug','entering if','entering if');
var firstNewLine = customLines.addNewLine();
firstNewLine.setEntityId(glEntityID);
firstNewLine.setDebitAmount(totalDebitAmount);
firstNewLine.setAccountId(421);
nlapiLogExecution('debug','firstline',firstNewLine);
var secondNewLine = customLines.addNewLine();
secondNewLine.setEntityId(glEntityID);
secondNewLine.setCreditAmount(totalDebitAmount);
secondNewLine.setAccountId(215);
nlapiLogExecution('debug','secondline',secondNewLine);
}
}
}
}
}
}
I get the below error The Custom GL Lines plug-in run for this transaction has failed. As a result, the GL Impact of this transaction might be incomplete. You can find more information and solve this issue on the Review Custom GL Plug-in Executions page. Could anyone please help me?
e
Are you seeing anything in Script Execution log from your debug statements?
v
yes what should i look into it?
e
Might be good to post what you’re seeing so we can see how far it’s making it in the script before failing. That might indicate what’s going wrong.
v
Anything is wrong?
its working than you all