Hopefully one of my last GL Script Questions. Is ...
# suitescript
s
Hopefully one of my last GL Script Questions. Is there a way to run a custom gl plugin in after submit or after record save?
s
I believe that is the only way to do it. More specifically, the GL plug-ins are triggered upon save, but it actually depends upon the standard GL lines being created first, which happens after submit. Then, once the standard GL lines are created, the Custom GL plug-ins are triggered. However, there are two processing options for GL plug-ins: synchronous (the default) and asynchronous. If you want to de-couple the custom GL processing so that it runs at a later time (usually a short delay, but can sometimes take longer), then you can set the plug-in to asynchronous mode. The downside is that if the custom GL plug-in fails, you won’t know about it at the time of saving the transaction. There is a page for asynchronous GL plug-in executions that someone needs to review periodically and manage, either re-trying failed executions, or notifying the plug-in developer if re-try doesn’t work.
s
Ok, i'll try async. The thing I'm basically needing, and I wouldn't need to do this, is to relate the standard line to which transaction line it is referencing. Do you know if that is possible?
@scottvonduhn We have a "return code" which is now a Classification so that it returns on every GL line. On this classification there is an income refund account and an asset refund account. I need to loop through the standard lines, and depending on what the item has as it's income & asset accounts, refund to the appropriate account.
s
I looked into that myself, and I think the answer is no. The standard GL lines and the item lines on the transaction don’t have a direct link to each other. However, there are clues as the where a standard lien came form, such as the Department, Class, and Location. The combination of those three values may be unique. Also, the total Amount of each item line may be unique enough to correlate to a standard line. But essentially, if you can find a way to structure the GL plug-in to not depend upon correlating the standard lines and item lines, I would do that. There will likely be cases where it can’t be uniquely determined.
s
Dang. Yeah, that's what I was doing was not depending on the standard lines. I was using a scripted search to pull back the lines I needed. The problem is on create 😢 . There is no internal id because it hasn't been created yet
s
The record itself is passed into the GL plug-in, to be used directly by the plug-in code. It is possible that the record exists only in memory still, and has not yet been persisted to the database.
However you can still loop through the item lines, the record sublist for item is available.
a search probably won’t work, unfortunately
s
Yeah, is there a way to loop through the items and re-create the entire GL Impact? That way I could tell what 1 or 2 lines it will create in the GL? Then I could use that info to add my additional lines
@scottvonduhn I feel slightly ashamed, but I'm ok with it. Any gl impact line that has a memo of "cost of sales" needs to be refunded to a COGS account. To make myself feel a little less slimy and dirty, I at least did toLowerCase() in my hard coding 🤢 lol!
s
I don’t think there is a way to “redo” the GL impact, unfortunately. definitely make use of any data you have available!