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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to set condition on datasource level for fields

(0) ShareShare
ReportReport
Posted on by 43

Dear community i am looking for answer that how i can set condition on datasource level in AX2012 .
Senario is something like this
i have 5 record lines

Example: We have three fields ID , Name, City
i want to set condition like this

if(city == 'abc')
{
SHOW NAME AND CITY COLUMN IN GRID
}
ELSE
{
SHOW ONLY ID IN GRID
}

How i can set this condition by using datasource level fields ?

I have the same question (0)
  • Suggested answer
    Komi Siabi Profile Picture
    13,089 Most Valuable Professional on at

    Hello, 

    1. 

    Firstly, you need to set the auto declaration property to Yes for all the fields on the grid : Id, Name, City.

    2. You might want to Hide these 3 fields on init of the form by doing this.

        public void init()
        {
            super();
            if(MainGrid_City.valueStr() == "Abc")
            {
                MainGrid_id.visible(false);
                MainGrid_name.visible(true);
                MainGrid_City.visible(true);
            }
            else
            {
                MainGrid_id.visible(true);
                MainGrid_name.visible(false);
                MainGrid_City.visible(false);
            }
            
        }

    MainGrid is the name of the Grid on your form.

  • Wajahat wasti Profile Picture
    43 on at

    Thanks Komi

    your answer resolve 50% my problem to set condition but another half is

    showing data from datasource with in condition

    i want to show values on behalf of condition  

  • Suggested answer
    Komi Siabi Profile Picture
    13,089 Most Valuable Professional on at

    Did you see the if statement in my code ?

    if(MainGrid_City.valueStr() == "Abc") /// Here is the condition

    You should also override the modifiedField method the City field and put the logic

  • Wajahat wasti Profile Picture
    43 on at

    But my question is about how i can set condition by datasource field ..your answer is for condition by grid column .

    thanks

  • Suggested answer
    Komi Siabi Profile Picture
    13,089 Most Valuable Professional on at

    the field on the datasource would have to be used on the form design if I am not mistaken?

    Maybe you should explain at what point exactly you want the condition.

    Is it on immediately you open the form ?

    When user select data on any of the field ?

  • Wajahat wasti Profile Picture
    43 on at

    I am working for purchase order lines grid .When we will open PO data will fetch on grid .

    Basically i want to reduce process time because display methods consume more time to access data from db .. This can be possible by using query and view then drop view as form source on form drop field from datasource to grid but having problem while implementing above condition .

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 683 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 563 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 398 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans