Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Button functionality in sales line.

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I have a  requirement where two fields from the item details form should get auto populated in the sales line when the item is selected. Once I was able to populate the fields of the item details form in the sales line. Now I have a button which, Based on the values of the fields, should enable or disable. For example, one field is PM_allowed. For a particular item if this is checked, then the button in the sales form should enable and vice-versa. This button opens a dialog box. Based on the value in the other field (no of chars) the dialog box should open a text box accepting that many characters.

The logic seems good. I managed to write code in the active method of the data source for the enable disable logic and write code in the button for the number of characters it displays. It works fine when I change the values in the sales line. The button works good and the no of chars are also as expected. However, when I try to get the values to populate directly from the item details form, the values are populated correctly in the sales line but the button functionality has a mind of its own. It suddenly doesn't take values from the sales line. I wrote display methods for populating the values in the sales line from the item details form. 

I am able to get the button to work fine and the fields to populate correctly but separately. When I combine them together, the button doesn't work. Any idea as to why this is happening? Any solutions?

*This post is locked for comments

  • Martin Dráb Profile Picture
    Martin Dráb 230,966 Most Valuable Professional on at
    RE: Button functionality in sales line.

    You're saying that your button doesn't work as expected, so why are you showing all other code? Shouldn't you show us the code in click()?

    Also, please use the debugger first to see what's going on; we can't do this work for you. We need to get this information from you.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Button functionality in sales line.

    I wrote an active method in the inventtable for the button logic.

    InventTable localinventtable;

       ;

       if(inventtable.agrPersonalization_allowed)

       personalize.enabled(true);

       else

       personalize.enabled(false);

       return ret;

    I wrote  display methods in the datasource to get the data from ItemDetails

    select agrPersonalisationchar from localinventtable

       where localinventtable.itemID == salesline.itemID;

    Then I wrote the code for the dialog in the button clicked method.

    All code runs fine, there are no errors. When I select an item in the salesline, the item's corresponding values are populated. However the button seems to ignore these values.

    If I remove the display methods for the fields in the salesline, and just give values there itself without auto populating from the Item details, the button works fine.

  • Martin Dráb Profile Picture
    Martin Dráb 230,966 Most Valuable Professional on at
    RE: Button functionality in sales line.

    Can you show us the code that doesn't work and explain which part doesn't behave as expected (after you reviewed the behaviour in debugger)?

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,187 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,966 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans