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)

Adding ranges on Forms

(0) ShareShare
ReportReport
Posted on by 634

Hi Guys,

I just need to add a range while opening a form, I am trying to do it through Init and Execute methods. Kindly let me know how I can add more records in the range. 

init method : 

VariableQBR=
this.query().dataSourceName('PBATableInstance').addRange(fieldnum(PBATableInstance,Variable));

Execute method:

VariableQBR.value(queryvalue('Test1'));

In the above, string Test1 is my variable to be displayed on the form (its working fine). How can I display variables Test1 and Test2 in the form ? how the code should be ?

Thanks in Advance 

*This post is locked for comments

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    301,020 Super User 2025 Season 2 on at

    Hi Alex,

    If you look at the General journal form, there is a neat example. On this form you can select to see Open, Posted or all Journals.

  • Community Member Profile Picture
    on at

    Hi!

    For example how add some range values

    class SysQuery

    Method

    // Can't be an instance method because new queryRun() until takes a query!
    
    
    
    static void addRangesFromKeyData(
    
       QueryBuildDataSource    qbds,
    
       KeyData                 keyData     // Must be a unique list of values!
    
       )
    
    {
    
       Map                     keyDataMap;
    
       MapEnumerator           me;
    
       // A local a method is used because the a variable can change type for each while loop
    
       anytype a()
    
       {
    
           anytype a;
    
           [a] = me.currentValue();
    
           return a;
    
       }
    
       //Only do Map::create() when container has at least 4 parameters. version,domain type,
    
       //range type and size
    
       if (conLen(keyData) >= 4)
    
       {
    
           keyDataMap = Map::create(keyData);
    
           me = keyDataMap.getEnumerator();
    
           while (me.moveNext())
    
           {
    
               qbds.addRange(me.currentKey()).value(queryValue(a()));
    
           }
    
       }
    
    }


  • D365  beginner Profile Picture
    634 on at

    Hi Andre,

    Thanks for the reply.

    I am looking on it as you said. Anyway can you share with me if its possible to do by a simple code ?

  • Verified answer
    Mea_ Profile Picture
    60,284 on at

    Hi Alex Antony,

    Here is simple code 

    VariableQBR.value(strFmt('((Variable == "%1") || (Variable == "%2"))', 
        queryValue("Test1"),
        queryValue("Test2")));
  • Suggested answer
    D365  beginner Profile Picture
    634 on at

    Thanks a lot Mr. Ievgen Miroshnikov. It works fine.

    You are always there with great support for AX beginners.

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
Ali Zaidi Profile Picture

Ali Zaidi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans