I am trying to use the new 'Chain Of Command' feature in D365FO by extending CustTable.
We need to check if a value has changed on the update method, before we log it in a new table.
[ExtensionOf(tableStr(CustTable))]
final class CustTable_Extension
{
void update(boolean _updateSmmBusRelTable = true, boolean _updateParty =
true)
{
CustTable custTable_Orig = this.orig();
boolean hasChanged = this.CreditMax != custTable_Orig.CreditMax;
next update(_updateSmmBusRelTable, _updateParty);
if(hasChanged)
{
//do something
}
}
}
However when running this code we get "Object is not set to an instance of an object" error. The error occurs because 'this' object is null. I also get the same error when calling "next update(_updateSmmBusRelTable, _updateParty);".
The documentation states: "This allows extending the logic of public and protected methods without the need to use event handlers. When you wrap a method, you can also access other public and protected methods and variables of the class."
Any ideas?
You have to (re-)compile package with CustTable
- Application Suite
with PU9 or newer.
See https://learn.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/get-started/whats-new-platform-update-9#supported-versions:
However, this functionality requires the class being augmented to be compiled on Platform update 9. Because the current releases of the Dynamics 365 for Finance and Operations, Enterprise editon applications have been compiled on Platform update 8 or earlier, you will need to recompile a base package (like Application Suite) on Platform update 9 or newer in order to wrap a method that is defined in that package
Try removing default parameters value from your wrapper method.
[ExtensionOf(tableStr(CustTable))]
final class CustTable_Extension
{
void update(boolean _updateSmmBusRelTable , boolean _updateParty )
{
CustTable custTable_Orig = this.orig();
boolean hasChanged = this.CreditMax != custTable_Orig.CreditMax;
next update(_updateSmmBusRelTable, _updateParty);
if(hasChanged)
{
//do something
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With