I’m fairly new to Dax and I’ve recently been given the task of adding a new field to an existing Purchase order report.

I’ll use the Tmp table set up already…PurchOrderTmp.

I’ve declared the table I want to use…CustVendExternalItem custVendExternalitem;

I seem to be having a problem calling the field on the report…

PurchOrderTmp.Externaltxt = custVendExternalITem.ExternalITemTxt;

Do I need to add a method or can I call this field from the class. I’ve tried everything I could find on the web but nothing works and I’m not sure what to do. Does anyone know how to call this field to the Purchase Order report?



First of all, which version of AX and (if applicable) which reporting framework (SSRS / MorphX) are you talking about?

Hey Martin,

I’m using AX-2012 R2 and working with SSRS reports.


You’re trying to edit PurchPurchaseOrder report, correct?

It uses a data provided class (PurchPurchaseOrderDP) to prepare the data, therefore you have to fill your field there. Nevertheless it seems to me that the right table is PurchPurchaseOrderTmp (filled in setPurchPurchaseOrderDetails() and returned by getPurchPurchaseOrderTmp()).

When this is done, you’ll open the report in Visual Studio, refresh the datasource (to see your new field) and use the field somewhere in the design.

Yes Martin, the PurchPurchaseOrder report is the SSRS report I’m working with. The problem I’m having is with the code to fill the PurchPurchaseOrderTmp.ExternalTxt field in the SetPurchPurchaseOrderDetails class. I can not get a value to the PurchPurchaseOrderTmp.ExternalTxt field.

Assigning to a field it trivial; so I guess your problem is in selecting data from CustVendExternalItem table. First of all, use the debugger to debug your code. If it doesn’t help to identify the cause, please explain what exactly is wrong and show us your code.

When I use the debugger there is no value to the field. " ".

I’ve declared the table:

CustVendExternalItem custVendExternalitem;

Then I found this code on this forum. I put it in the DP class but can’t call it from the SetPurchPurchaseOrderDetails class


new CustExternalItemDescription(CustConfirmTrans.ItemId,




return custExternalItemDescription.externalItemFreeTxt();ExternalItemFreeTxt custExtItemDesc_ag(CustConfirmTrans custConfirmTrans)


CustExternalItemDescription custExternalItemDescription;


custExternalItemDescription =

then I call the table:

PurchPurchaseOrderTmp.Externaltxt = custVendExternalITem.ExternalITemTxt;

static ExternalItemFreeTxt custExtItemDesc_ag(CustConfirmTrans custConfirmTrans)


CustExternalItemDescription custExternalItemDescription;


custExternalItemDescription =

new CustExternalItemDescription(CustConfirmTrans.ItemId,






Hey Martin, I’m sure that code isn’t right…

What do you mean by using CustConfirmTrans in a purchase order report? It doesn’t make any sense to me. Please never use pieces of code that you found somewhere and you don’t understand what they’re doing. Many bugs are introduced by this process…

Stop and think what you want to achieve. For example, where do you want to get the item ID? What about on the purchase order line?

Also notice that it’s purchase order, therefore using VendExternalItemDescription would make better sense to me than CustExternalItemDescription.

By the way, doesn’t PurchPurchaseOrderTmp.ExternalItemNum already contain what you need?

That’s good advice Martin.

It doesn’t make sense to me either…I’ll remove it.

I think I’d get the item ID from the invent table and inner join it to the CustVendExternalitem table to get the ExternalTxt.

Does this make more sense?


CustVendExternalItem findExternalItemtxt_ag(ItemId itemId, boolean update = false)


CustVendExternalItem sbCustVendExternalItem;

InventTable sbInventtable;


select ExternalItemTxt from sbCustVendExternalItem


sbCustVendExternalItem // same as writing inner join


return sbcustVendExternalItem;sbCustVendExternalItem.ItemId == sbInventTable.ItemId;

No, it doesn’t. Again, for which item ID do you want to find an external description? And why does your method has a parameter for itemId that you never used anywhere?

Why exactly doesn’t the existing ExternalItemId meet your requirements?

And please, pay attention to formatting of your posts; the code is barely readable.

No the end user will populate this filed and then call it on the Purchase Order report.

I think I would like to use the CustVendExternalItem.ItemID to find the ExternalITemTxt…

But I’m not sure.

Your right. The Purchase Order Line would be a good place to get the ItemID.

Hey Martin,

Any ideas how I can fill the ExternalTxt field from the CustVendExternalItem table in the DP class?

The value is already filled into PurchPurchaseOrderTmp.ExternalItemNum alread. Developing it again is a waste of time, nevertheless if you want, look at how the ExternalItemId field is filled into PurchLine table.

Hey Martin Thanks for all your help.

I do need to get the ExternalItemTxt field to populate.

This is how the ExternalItemId is populated:

purchPurchaseOrderTmp.ExternalItemNum = Formletter::JournalExternalItemId(ModuleInventPurchSales::purch, purchLineAllVersions.ExternalId);

I created a new class JournalExternalItemTxt which complies but there is no ExternalItemTxt field in the purchLineAllVersions query…I’ve tried to add a new data source, etc but its not working. How can I add the field ExternalItemTxt to the PurchLineAllVersions table?

Sorry, I didn’t notice you want Txt, not ID. In that case, I would preferably either set it to the Name field (see PurchLine.initFromVendExternalItemDescription() for details), or indedd find it by VendExternalItemDescription.externalItemFreeTxt().

Regading PurchLineAllVersion, simply look at its definition in AOT. You’ll see it’s an union of two views, and PurchLineNotArchivedVersions and PurchLineArchivedVersions (based on PurchLine and PurchLineHistory tables). You would add a custom field to both tables and propagate it to the views and the query.