web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Unbound control question

(0) ShareShare
ReportReport
Posted on by 1,005

I'm new to X++, and I want to put an unbound
checkbox on a tab in the sales header form
(SalesTable).  When the configure line button is
pressed on the bottom half of the form for a sales
line, I need to have code in that other class
check the on/off status of the unbound control in
the SalesTable form and do something.  I really
don't need the database to record the status.

The current status is I've placed the checkbox on
the form, see it on the diaply and can click it,
but can't refer to it.

My question is how do I refer to the unbound
control in the SalesTable form from another class
and, is this the right approach?

 

*This post is locked for comments

I have the same question (0)
  • Muhammad Afsar Khan Profile Picture
    2,676 on at

    You can do it via a display method on form.

  • Kevin Murray Profile Picture
    1,005 on at

    The flow is...the user will click a checkbox on SalesTable when they want the functionality to work, unmark when they don't. They will then press the configure button on the lower SalesOrder screen which will invoke Product Builder. The button code has been modified to include a class that will copy the sales line (or won't if the checkbox hasn't been marked), so there really isn't a form, just a class. In the class I want code to go (psuedocode: if flag checked then continue, otherwise return). This is all AX 2009 but probably the same regardless.

    Unless I'm totally misunderstanding.

  • Muhammad Afsar Khan Profile Picture
    2,676 on at

     

    1. Declare Map/List variable in classDelaration and create object in forms init method like:

    Map   salesTableMap;

    salesTableMap = new Map(Types::String, Types::Record); // please use list instead of MAP

    2. Create edit method on SalesTable datasource:

    edit NoYesId markUnboundedChkBox(boolean _set, SalesTable _salesTable, NoYesId _value)

     {;

     if(_set)

     {

         if(_value)

            salesTableMap.insert(_salesTable.SalesId, _salesTable);

         else

            salesTableMap.remove(_salesTable.SalesId);

         }

         return(salesTableMap.exists(_salesTable.SalesId));

     }

    3. drop this edit method on form.

    4. Write following code on button:

    void clicked()

    {

        super();

        if (salesTableMap.exists(salesTable.SalesId))

        info("Enable");

        else

        info("Disable");

    }

    Regards,

    -Afsar

     

    mafsarkhan.blogspot.com

  • Denis Patrakov Profile Picture
    on at

    [quote user="Kevin Murray"]The flow is...the user will click a checkbox on SalesTable when they want the functionality to work, unmark when they don't.[/quote]This is not the way in which the standard application works. In the standard application a user must select records on a grid he/she needs to be processed (using Shift or Ctrl to mark multiple records) and then just press an appropriate button on a form. The menu item for the button must have MultiSelect set to Yes. A class that is called via the menu item should collect all the selected records from the datasource and then process them on the server side. To grab all the selected records you can use FormLetter::getFormRecord() - it return a packed map (RecId -> Record buffer) with the selected records; in your class you can unpack the map on the server side and process them one by one. This perfectly works regardless of the number of records selected, i.e. even if a user selects just one single record, and you don't have to modify every form to to be able to process multiple records at once.

    As to implenemting an edit method backed by a Map or something, consider this:

    • If a users marks some records and then applies a query filter that narrows the resultset (but marked records are still in the resultset and thus can be visible on a form), what are you going to do with the marks stored in a collection class? Will you just clear all the marks, or keep them, or try to keep only marks for records in the resultset?
    • If a user removes a filter applied earlier, will he/she be able to see marks that were set before applying the filter?
    • If you deside to keep marks only for those records in the current resultset (i.e somehow remove marks for those record that a user cannot see on the form with the current query filters applied) then how are you going to achieve that? How will it impact performance, client-server traffic and overall workload?

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans