Question Status

Verified
Brad Lythgoe asked a question on 12 Sep 2013 2:13 PM

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?

Reply
Verified Answer
Brad Lythgoe responded on 13 Sep 2013 8:47 AM

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.

Reply
Suggested Answer
André Arnaud de Calavon responded on 13 Sep 2013 7:40 AM

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.

Reply
Dominic Lee responded on 12 Sep 2013 10:46 PM

Hi Bradly,

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

kind regards,

Dominic Lee

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.

Reply
Brad Lythgoe responded on 13 Sep 2013 7:34 AM

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();

   }

Reply
Brad Lythgoe responded on 13 Sep 2013 7:34 AM

The second case for GenerateInventDimIdDefault is not reached.

Reply
Suggested Answer
André Arnaud de Calavon responded on 13 Sep 2013 7:40 AM

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.

Reply
Brad Lythgoe responded on 13 Sep 2013 8:05 AM

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.

Reply
Verified Answer
Brad Lythgoe responded on 13 Sep 2013 8:47 AM

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.

Reply
André Arnaud de Calavon responded on 13 Sep 2013 1:28 PM

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.

Reply
Brad Lythgoe responded on 13 Sep 2013 1:43 PM

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

Reply