Hi,
The ProjEmplTrans table has a particular static method called initTransFromJournal that I would like to extend.
Here is a cut down version of it:
public static ProjEmplTrans initTransFromJournal(ProjJournalTrans _projJournalTrans)
{
ProjEmplTrans projEmplTrans;
...
projEmplTrans.TransId = _projJournalTrans.TransId;
...
return projEmplTrans;
}
So this method has a single argument of ProjJournalTrans and it returns an instance of ProjEmplTrans.
As you may imagine, the ProjEmplTrans buffer is initialized from the ProjJournalTrans buffer.
I have added an additional field called InventAssetId to ProjJournalTrans and ProjEmplTrans.
When ProjEmplTrans.initTransFromJournal is executed I would like the InventAssetId to be copied from the journal transaction to the empl transaction like:
public static ProjEmplTrans initTransFromJournal(ProjJournalTrans _projJournalTrans)
{
ProjEmplTrans projEmplTrans;
...
projEmplTrans.TransId = _projJournalTrans.TransId;
projEmplTrans.InventAssetId = _projJournalTrans.InventAssetId;
...
return projEmplTrans;
}
Since overlayering is not an option, I created a POST event handler. But for some reason, the XppPrePostArgs object does not contain the ProjEmplTrans return value - by this I mean that args.getReturnValue(); does not yield and instance of projEmplTrans.
Given that this approach does not seem to work, how can I achieve this?
[PostHandlerFor(tableStr(ProjEmplTrans), tableStaticMethodStr(ProjEmplTrans, initTransFromJournal))]
public static void ProjEmplTrans_Post_initTransFromJournal(XppPrePostArgs args)
{
ProjEmplTrans projEmplTrans = args.getReturnValue();
ProjJournalTrans projJournalTrans = args.getArg("_projJournalTrans");
;
if(projJournalTrans.TransId)
{
info(strfmt("ProjJournalTrans exists and has TransId %1", projJournalTrans.TransId));
}
else
{
info("There is no ProjJournalTrans");
}
if(projEmplTrans.TransId)
{
info(strfmt("ProjEmplTransTable exists and has TransId %1", projEmplTrans.TransId));
}
else
{
info("There is no ProjEmplTransTable");
}
projEmplTrans.InventAssetId = projJournalTrans.InventAssetId;
}
Thanks
Luke