Question Status

Suggested Answer
IRodman asked a question on 25 Jul 2013 9:50 AM

Hi all,

I am using AX 2009, I have that display method that takes the SiteID from the InventDim Table and display it on the CustGrossMargingByItem_NA Report. So here is my method:

Display InventSiteId Site()
{
InventDim inventDim;

Select InventSiteId From InventDim Where InventDim.RecId == CustInvoiceTrans.RecId;
Return inventDim.InventSiteId;
}

The problem is that it doesn't work. I have an error message appearing, there is a red line under the 5th line, from "Select" to "CustInvoiceTrans" and the error message sais that the "Table doesn't have this field".

I don't understand what's wrong, I am basically calling the InventSiteId field from the InventDim Table where the field RecId of that table is the same that RecId in the CustInvoiceTrans table. I did it because InventDim is not in my datasource, so I called it and I defined it before hand. The field that interest me is InventSiteId and the only place where I can find it and have a connection with one of the table my Report is using is the InventDim Table.

If one of you can help me please let me know.

Regards

Reply
Suggested Answer
Petr Janík responded on 25 Jul 2013 1:46 PM

Hi Irodman,

The link InventDim.RecId == CustInvoiceTrans.RecId does not make sense. The table CustInvoiceTrans has a field InventDimId, which you should use.

Select firstonly InventSiteId From InventDim Where InventDim.InventDimId == CustInvoiceTrans.InventDimId;

Regards

Reply
Andy Adamak responded on 25 Jul 2013 2:25 PM

First, you do not want to match on RecId.  You want to match on InventDimId.  Second, try to compile and sync the application.  Third, where are you defining this display method?  On the CustInvoiceTrans table?  And you're to display the site for a report?  From what I understand the display methods are used for displaying data in AX forms, not reports.  For a report you could just add invent dim to your query or in your RDP... not sure how you're going about the Report, but this is what I'd define on the CustInvoiceTrans table to display InventSiteId:

display InventSiteId displayInventSiteId()

{

      return InventDim::find(this.InventDimId).InventSiteId;

}

Reply
MBrown1185 responded on 25 Jul 2013 9:45 PM

Adding to Any, is there any specific reason for using display method instead of adding InventDim to form's datasource?  It will be a lot more faster and efficient than Display Methods.

Regards,

Michael Brown

Reply
IRodman responded on 26 Jul 2013 2:53 AM

@MBROWN1185 I tried to use InventDim on the Datasource but when I generate the Report, it doesn't appear. I don't even see the field , that's why I tried my luck with the Display Method.

Reply
Andy Adamak responded on 26 Jul 2013 6:54 AM

Did you do your join(relationship) correctly?  If you're trying to join on RecId as above, that is wrong.  You have to set up your relationship on InventDimId. Then in the fields node of your datasource you have to add InventSiteId.  After all that, it doesn't magically show on the report... did you go in and modify the report in VS 2010?  You have to open the report, modify your dataset to bring in the new field, then add it into the report design.  

I was wrong on the display methods, however.  I forgot that you CAN select display methods when creating your dataset in the report designer for VS.  

Reply
IRodman responded on 28 Jul 2013 11:07 AM

I al using AX2009 and it doesn't work with VS2010. Can someone give me a solution concerning this problem please? I tried the display method and I changed it like you guys suggested but it didn't work. I tried the datasource by adding InventDim to it and it didn't work. I tried to set connexion between tables and it didn't work. I don't know what's wrong but something is since it doesn't work.

Reply
Suggested Answer
Petr Janík responded on 25 Jul 2013 1:46 PM

Hi Irodman,

The link InventDim.RecId == CustInvoiceTrans.RecId does not make sense. The table CustInvoiceTrans has a field InventDimId, which you should use.

Select firstonly InventSiteId From InventDim Where InventDim.InventDimId == CustInvoiceTrans.InventDimId;

Regards

Reply