Get value from display method

Hi All,

I have a display method which shows the ItemId on the report. Now, I need to pass this value(ItemId) to the different method. Here’s the some sample:


This is displaying my ItemID:

display ItemId itemId()
{
ItemId _itemId = FormLetter::journalItemId(ModuleInventPurchSales::Sales, custPackingSlipTrans.ItemId, custPackingSlipTrans.ExternalItemId);

if (inventDimReport.isItemDimItemId())
{
_itemId += inventDimReport.reportStrItemId(inventDim);
}

return _itemId;
}


Now, I need to create a new method and pass this Item value. Is it doable?

Thanks much!

You are best doing this as a global variable so you can use and re-use your value.

Set the variable in the ClassDeclaration() as this makes it global throughout the report element.

Then pass the value into the global variable in the Fetch() method that will pass the current ItemId into your global variable.

Then write a simple display method that will return your global variable where required.

Alternatively why don’t you re-use the same method elsewhere?

Thank you for reply!!

Sorry, I’m new in ax…Can we go a little bit in details?

So, it should be something like this:


ClassDecaration()::

ItemId _itemId


fetch()

_itemId = FormLetter::journalItemId(ModuleInventPurchSales::Sales, custPackingSlipTrans.ItemId, custPackingSlipTrans.ExternalItemId);


How to use this variables in new display method?

Something like:

dispaly str Item()

{

str name;

name = _itemId;

}

appriciate your help!

dispaly str Item()

{

retuen _itemId;

}

Note: don’t prefix your variable with _. It applies to method parametes

Will try it…Thanks much, Kranthi!

But, If I need to assign a returned value to the string, let’s say:

display str Item()

{

str name;

;

name=_itemId;

}

will it work (not sure if syntax is correct, it just some thoughts)

Thanks much!

For your display method you need to use something like the following:-

Display ItemId _apmItemId()
{
return itemID;
}

You need to define the data type or EDT you are returning, in my example “ItemId”, then name your method _apmItemId.
You then return your variable which you have passed the data into via the Fetch() method “return itemId”.

This method goes directly into the report section you are returning the data.

You then simply drag and drop your method into the report section which creates a data field.

Can I suggest you work through the DEV packs and look for sample display methods in some of these resources:-

MorphX IT
Inside Microsoft Dynamics AX 2009
AX 2009 Development Cookbook
Dynamics AX Getting Started

Thank you for your reply and suggestion!

Probably, I should have been more specific. I don’t have a problem to display my item(ItemId).
My scope is not to display this item, I need hold Itemid value in var. I have a method(itemId() ) under CustPackingSlipTrans table, which returns an ItemId.

I have created a new ItemId var in ClassDeclaration(under SalesPackingSlip method) and I need to assign a value form itemId() method;

Be more specific: in PageFooter section i have a string control which holds a message(txt).
This message needs to be hide/invisible when condition is true in ItemID. We have items(InventTable)masked as: INT-XXXXX && XXXXX
Let’s say:

str name;
str res;
name = [ClassDeclaration].var(which holds itemid value);
res = substr(name,1,3)

and condiotional block, something like this:
if(res ==‘INT’)

{
return ‘display message method’;
}

else
{
return ‘’;
}


I have suggested to add a new flag/field in InventTable and check the item. It could be a better approch :slight_smile:

Thanks,

Alex