Brewsterware

March 11, 2022

postTargetProcess not being called on child entities in a composite entity

Filed under: 365 for Finance and Operations,Data Entities,Software — Joe Brewer @ 2:37 pm

If you have ever done any testing and development with data entities you may have noticed that the static method postTargetProcess() does not get called for child entities in a composite data entity. For a recent project I needed this method to be called on the SalesOrderHeaderChargeV2Entity and SalesOrderLineV2Entity when data is imported using the SalesOrdersV3 composite data entity is used to import sales orders.

The code below can be used to fix this issue. Because the postTargetProcess method is called on the root data entity only, SalesOrderHeaderV2Entity in this case, the table DMFDefinitionGroupExecution can be queried and the appropriate record can be passed to the postTargetProcess method on the child entities. The “like” operator on line 12 is used to make sure that the postTargetProcess method is not called for SalesOrderHeaderChargeV2Entity and SalesOrderLineV2Entity when SalesOrderHeaderV2Entity is used by itself.

[ExtensionOf(tablestr(SalesOrderHeaderV2Entity))]
final class SalesOrderHeaderV2Entity_Extension
{
	public static void postTargetProcess(DMFDefinitionGroupExecution _dmfDefinitionGroupExecution)
    {
        DMFDefinitionGroupExecution localDefinitionGroupExecution;

        while select localDefinitionGroupExecution
            where localDefinitionGroupExecution.DefinitionGroup == _dmfDefinitionGroupExecution.DefinitionGroup &&
                    localDefinitionGroupExecution.ExecutionId == _dmfDefinitionGroupExecution.ExecutionId &&
                    localDefinitionGroupExecution.RecId != _dmfDefinitionGroupExecution.RecId &&
                    localDefinitionGroupExecution.Entity like 'Sales orders composite V3*'
        {
            switch (localDefinitionGroupExecution.EntityXMLName)
            {
                case dataentityviewstr(SalesOrderLineV2Entity):
                    SalesOrderLineV2Entity::postTargetProcess(localDefinitionGroupExecution);
                    break;

                case dataentityviewstr(SalesOrderHeaderChargeV2Entity):
                    SalesOrderHeaderChargeV2Entity::postTargetProcess(localDefinitionGroupExecution);
                    break;
            }
        }
    }
}

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress