Good Morning,
I have to insert in a custom table, data from an invent journal transfer, but I need to insert in that table after the journal is posted.
I found the InventJournalCheckPost class, that is called from the post button (InventJournalTransfer Form), but I don't know where to put my code to insert data to that custom table.
Please could you tell me where can I put some extra code, after the journal transfer is successfully posted?
Thansk a lot
*This post is locked for comments
Brandon thank you very much
It worked perfecly!
InventJournalTable orig = this.orig();
super();
if( this.JournalType == InventJournalType::Transfer)
{
if (this.Posted && !orig.Posted)
{
//insert code
}
}
May I suggest that you check specifically for when Posted is true and was just changed from false? Otherwise you might see additional updates to the record creating more records in your secondary table than you like.
For example, in the declaration section, add
InventJournalTable orig = this.orig();
Then, in your code block,
if (this.Posted == true && orig.Posted == false)
Or, more simply since the field is boolean,
if (this.Posted && !orig.Posted)
Thank you both!, Brandon and Sohaib,
It worked perfectly!
//on table InventJournalTable
public void update()
{
super();
if( this.JournalType == InventJournalType::Transfer )
{
if( this.posted == NoYes::Yes )
{
// code to insert into custom table
}
}
}
Moreover, add an IF:-
if(JournalType == InventJournalType::Transfer)
{
// add data in my custom table
}
InventJournalCheckPost does not actually do much work. It's the InventJournalCheckPost_Movement class you're probably interested in.
Since it inherits from JournalCheckPostLedger, which inherits from JournalCheckPost, to understand this class requires a bit of digging.
Basically, the journal header gets marked as posted in runPostEnd(), so anything after the super() in that method on InventJournalCheckPost_Movement should work. Also the runEnd() method follows runPostEnd(), so there is a good place. You will have to override these in the InventJournalCheckPost_Movement class.
Alternately, you could just add your code to InventJournalTable in the update() method, checking for the Posted field to turn Yes, and then add your record there, and that might just be easier all around.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156