In my import export Entity Class, getReturnFields, only one of my 2 functions is being reached in the switch.

In my import export Entity Class, getReturnFields, only one of my 2 functions is being reached in the switch.

This question is answered

I have 3 switch cases in there (1 is for null), however, only 1 is getting reached which ends up not defaulting the right mapping for Staging to Target.

Any idea why it doesn't call my getReturnFields more than once?

Verified Answer
  • I figured it out.

    When dealing with DMF Entities, the Field Groups that are associated with the Methods in the EntityClass should be unique in that their fields shouldn't be the same.  I had ItemId in each of my field groups.

All Replies
  • Hi Bradly,

    Can you post the code here and explain which part is not reached?

    My blog | PBC

    This forum post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

  • switch (_name)

       {

           case methodStr(DMFInventItemPurchSetupDOSEntityClass, GenerateInventDimId) :

               con += [fieldstrToTargetXML(fieldStr(InventItemPurchSetup, InventDimId), purchSetupDataSourceName)];

               con += [fieldstrToTargetXML(fieldStr(InventItemInventSetup, InventDimId), inventSetupDataSourceName)];

               con += [fieldstrToTargetXML(fieldStr(InventItemSalesSetup, InventDimId), salesSetupDataSourceName)];

               break;

           case methodStr(DMFInventItemPurchSetupDOSEntityClass, GenerateInventDimIdDefault) :

               con += [fieldstrToTargetXML(fieldStr(InventItemPurchSetup, InventDimIdDefault), purchSetupDataSourceName)];

               con += [fieldstrToTargetXML(fieldStr(InventItemInventSetup, InventDimIdDefault), inventSetupDataSourceName)];

               con += [fieldstrToTargetXML(fieldStr(InventItemSalesSetup, InventDimIdDefault), salesSetupDataSourceName)];

               break;

           default :

           con = conNull();

       }

  • The second case for GenerateInventDimIdDefault is not reached.

  • Hi Bradly,

    Because of the 'break'-statement other case statements are not executed. In this scenario you can delete this statement to have all case statements evaluated.

    See also this link: msdn.microsoft.com/.../aa607181.aspx

    kind regards,

    André Arnaud de Calavon  |  Microsoft Dynamics AX Solution architect  |  My blog  |  My company

    This post is my own opinion and does not necessarily reflect the opinion or view of my company, Microsoft, both its employees, or other MVPs.

  • There should be a break.  the 'getReturnFields' method inside the DMFEntityClass should be called for each 'Generate' method you have.  It is only being called once for my entity.  Removing the break is not what should happen.

  • I figured it out.

    When dealing with DMF Entities, the Field Groups that are associated with the Methods in the EntityClass should be unique in that their fields shouldn't be the same.  I had ItemId in each of my field groups.

  • Hi Bradly,

    Thanks for sharing your solution. I never guessed you made the mistake in the field groups...

    kind regards,

    André Arnaud de Calavon  |  Microsoft Dynamics AX Solution architect  |  My blog  |  My company

    This post is my own opinion and does not necessarily reflect the opinion or view of my company, Microsoft, both its employees, or other MVPs.

  • Yeah... Simple mistake, however, I had no idea it would cause a problem.