In this example I will be showing how to extend or overwrite dataentity methods.
In D365 7.1 and later versions Microsoft is not allowing to overwrite the standard objects. To overcome this, we need to use extensions.
We follow the same concept for extending tables, forms and classes methods.
Below example I'm overwriting/extending postload method in SalesOrderHeaderV2Entity entity.
Here I'm assigning sales order createddatetime value to some custom field.
[ExtensionOf(tableStr(SalesOrderHeaderV2Entity))]
final class SWClass_SalesOrderHeaderV2Entity_Extension
{
public void postload()
{
next postload();
SalesOrderHeaderV2Entity SalesOrderHeaderV2Entity = this;
SalesTable salesTable = SalesTable::find(SalesOrderHeaderV2Entity.SalesOrderNumber);
SalesOrderHeaderV2Entity.customdate += date2Str(salesTable.createddateandtime, 213,
DateMonth::Digits2,
DateSeparator::Slash,
DateDay::Digits2,
DateSeparator::Slash,
DateYear::Digits4);
}
}
}
In the same way you can extend other methods as well.
@Rahul
In D365 7.1 and later versions Microsoft is not allowing to overwrite the standard objects. To overcome this, we need to use extensions.
We follow the same concept for extending tables, forms and classes methods.
Below example I'm overwriting/extending postload method in SalesOrderHeaderV2Entity entity.
Here I'm assigning sales order createddatetime value to some custom field.
[ExtensionOf(tableStr(SalesOrderHeaderV2Entity))]
final class SWClass_SalesOrderHeaderV2Entity_Extension
{
public void postload()
{
next postload();
SalesOrderHeaderV2Entity SalesOrderHeaderV2Entity = this;
SalesTable salesTable = SalesTable::find(SalesOrderHeaderV2Entity.SalesOrderNumber);
SalesOrderHeaderV2Entity.customdate += date2Str(salesTable.createddateandtime, 213,
DateMonth::Digits2,
DateSeparator::Slash,
DateDay::Digits2,
DateSeparator::Slash,
DateYear::Digits4);
}
}
}
In the same way you can extend other methods as well.
@Rahul
This is my first time i visit here and I found so many interesting stuff in your blog especially it's discussion, thank you.
ReplyDeletepożyczka w 5 minut bez zaświadczeń