Custom GL Lines Plugin error due to a failed valid...
# ask-stanley-ai
m
Custom GL Lines Plugin error due to a failed validation of script output: Setting entity on GL line with account of type AcctPay is not allowed for book-specific transaction
c
AI generated answer (using internal Slack threads):
****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ****** The error you're encountering, "Setting entity on GL line with account of type AcctPay is not allowed for book-specific transaction", is due to the fact that you're trying to set an entity on a GL line with an account type that is not allowed for book-specific transactions. In NetSuite, certain account types are not allowed to be associated with certain entity types. For example, you cannot associate a vendor with an accounts payable account or a customer with an accounts receivable account. This is a restriction in NetSuite's system to ensure the integrity of the accounting books. In your case, you're trying to set an entity on a GL line with an account of type AcctPay (Accounts Payable), which is not allowed for book-specific transactions. A book-specific transaction refers to a transaction that is specific to a certain set of accounting books. If you have the Multi-Book Accounting feature enabled in NetSuite, each subsidiary (and therefore vendors and customers via their subsidiary) are associated with certain books. To resolve this issue, you need to ensure that the account type specified in
setAccountId(accountId)
is appropriate for the entity type. You can refer to SuiteAnswers article 102994 and 36439 for more information on this topic. Here's a snippet of your code where you might need to make adjustments:
Copy code
javascript
if(glDebitAmount > 0 && glDebitAmount !== null){
    var firstNewLine = customLines.addNewLine();
    firstNewLine.setCreditAmount(glDebitAmount);
}else if(glCreditAmount > 0 && glCreditAmount !== null){
    var firstNewLine = customLines.addNewLine();
    firstNewLine.setDebitAmount(glCreditAmount);
}
firstNewLine.setEntityId(glEntityId);
firstNewLine.setAccountId(glAccountID);
firstNewLine.setMemo(glMemo);
//firstNewLine.setSubsidiaryId(glSubsidiary);
firstNewLine.setClassId(glClass);
firstNewLine.setDepartmentId(glDepartment);
In this code, you're setting the entity ID and account ID for the new GL line. You need to ensure that the account ID you're setting is appropriate for the entity type.
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.915206075
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.889373481
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.863608062
Please provide your feedback on this answer.