Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Creating a Form in AX 2012

(0) ShareShare
ReportReport
Posted on by 485

Hello Everyone,

I need some help to create a form using fields from InventTable and InventTableModule. The two fields the form will use are ItemID and SalesPrice. 

This is the job to get the sales price base on the itemid passed.

static void AXListPrices(Args _args)
{
InventTable it;
InventTableModule itm;
;
while select it where it.ItemId=="100001"
join itm where it.itemid == itm.ItemId
&& itm.ModuleType == ModuleInventPurchSales::Sales
{
       info(strFmt("%1", itm.Price));
}
}

All I need to go is the following......

Create a form that allow the user to choose a item number and then the corresponding sale price will be displayed. 

Please my friends that all i want o do any help, suggestions or example would be greatly appreciated.

*This post is locked for comments

  • Lionel07 Profile Picture
    Lionel07 485 on at
    RE: Creating a Form in AX 2012

    Thanks a million Rustem, I have been working on this over a week now. Thanks much again am good to go now. Really appreciate your help.

  • Verified answer
    Rustem Galiamov Profile Picture
    Rustem Galiamov 8,072 on at
    RE: Creating a Form in AX 2012

    You don't need to create a table.

    Just create a form with two fields:

    Screenshot-2018_2D00_12_2D00_30-at-19.41.12.png

    1. Item number - create string field and set EDT ItemId

    Screenshot-2018_2D00_12_2D00_30-at-19.40.46.png

    2. Item sales price - create real field and set EDT SalesPrice, AutoDeclaration = YES, AllowEdit = No

    Screenshot-2018_2D00_12_2D00_30-at-19.41.01.png 

    3. On Item number field override modified() method and write this code:

    Screenshot-2018_2D00_12_2D00_30-at-19.41.12.png

    public boolean modified()
    {
        boolean           ret;
    
        ret = super();
    
        ItemSalesPrice.realValue(InventTableModule::find(this.valueStr(), ModuleInventPurchSales::Sales).Price);
    
        return ret;
    }


  • Lionel07 Profile Picture
    Lionel07 485 on at
    RE: Creating a Form in AX 2012

    I am trying my best to follow the recommendations because am not clear as to what i must do.

    this is what i have done:

    1. Created a new table with two fields image newtable

    newtableFORM.png

    with this table i used the EDT on ItemID to get the lookup from InventTable (see relation)

    2. I created a form and use table (newtable) as its datasource see image newtableform

    newtableFORM.png

    3. Under the ItemID field I override the modified method by adding this code:

    using the following code:

    public void modified()
    {
    InventTable it;
    InventTableModule itm;
    ItemPrice itemp;
    ;

    if(itemp.ItemIDCost)

    {

    while select itemp where itemp.ItemIDCost==it.ItemId
    join itm where it.itemid == itm.ItemId
    && itm.ModuleType == ModuleInventPurchSales::Sales
    {
    itemp.ItemPriceShow = strFmt("",itm.Price);
    }

    }
    }

     After doing this nothing happens. The Price is not displaying in the in the other field. Can you please help me? i have a deadline and need to complete this. Please your help on it.  

    my form

    1385.FORM.png

    please help

  • Lionel07 Profile Picture
    Lionel07 485 on at
    RE: Creating a Form in AX 2012

    thanks for responding Rustem,

    I am trying my best to follow your recommendation because am not clear as to what i must do.

    this is what i have done:

    1. Created a new table with two fields image newtable

    newtableFORM.png

    with this table i used the EDT on ItemID to get the lookup from InventTable (see relation)

    2. I created a form and use table (newtable) as its datasource see image newtableform

    newtableFORM.png

    3. Under the ItemID field I override the modified method by adding this code:

    using the following code:

    public void modified()
    {
    InventTable it;
    InventTableModule itm;
    ItemPrice itemp;
    ;

    if(itemp.ItemIDCost)

    {

    while select itemp where itemp.ItemIDCost==it.ItemId
    join itm where it.itemid == itm.ItemId
    && itm.ModuleType == ModuleInventPurchSales::Sales
    {
    itemp.ItemPriceShow = strFmt("",itm.Price);
    }

    }
    }

     After doing this nothing happens. The Price is not displaying in the in the other field. Can you please help me? i have a deadline and need to complete this. Please your help on it.  

    my form

    1385.FORM.png

  • Lifeisbelieveful Profile Picture
    Lifeisbelieveful 345 on at
    RE: Creating a Form in AX 2012

    You can use the Item Id value from the form as follow, then you can use the value in where condition to select sales price.

    _itemId =ItemId.valueStr(); // ItemId is stringEdit which you are going to make for Item Id and should change the property "AutoDeclaration" to Yes.

  • Suggested answer
    Rustem Galiamov Profile Picture
    Rustem Galiamov 8,072 on at
    RE: Creating a Form in AX 2012

    Hi Lionel07!

    You want to create a form with only two fields?

    So, create a field with items lookup and a field (set allowEdit to NO) which will display sales price. Then override modified() method on first field and fill sales price value.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans