web
You’re offline. This is a read only version of the page.
close
Skip to main content
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,049 Most Valuable Professional on at
    RE: How to set condition on datasource level for fields

    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
    RE: How to set condition on datasource level for fields

    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,049 Most Valuable Professional on at
    RE: How to set condition on datasource level for fields

    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
    RE: How to set condition on datasource level for fields

    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,049 Most Valuable Professional on at
    RE: How to set condition on datasource level for fields

    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
    RE: How to set condition on datasource level for fields

    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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

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

#2
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 636

#3
Martin Dráb Profile Picture

Martin Dráb 553 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans