Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Unanswered

How to check if a column is visible?

(0) ShareShare
ReportReport
Posted on by 737

Hello,

Is it possible to check if the user has added any new column to the grid view?

Thanks.

  • Shooowtek Profile Picture
    Shooowtek 737 on at
    RE: How to check if a column is visible?

    You are right, sorry for the mistake.

  • Martin Dráb Profile Picture
    Martin Dráb 230,868 Most Valuable Professional on at
    RE: How to check if a column is visible?

    You're in a wrong thread - this one is about "checking if the user has added any new column to the grid view". You probably wanted to put it onto your thread   .

  • Shooowtek Profile Picture
    Shooowtek 737 on at
    RE: How to check if a column is visible?

    Hello,

    I have a display method created on the InventSum datasoure of the InventOnhandItem form. Based on the debugging I did on this method, _inventSum is "No data selected"

    This method calls the myMethod method from the InventSum table extension.

    [ExtensionOf(formDataSourceStr(InventOnhandItem, InventSum))]
    final class InventOnhandItem_InventSum_XXX_Extension
    {
        display Qty myDisplay(InventSum _inventSum)
        {
            FormDataSource inventSum_ds = _inventSum.datasource();
            InventSum inventSum = inventSum_ds.cursor();
            FormDataSource inventDim_ds = inventSum_ds.formRun().dataSource("InventDim");
    
            return InventSum.MyMethod(_inventSum, InventDim_ds);
        }
    
    }

    [ExtensionOf(tableStr(InventSum))]
    final class InventSum_XXX_Extension
    {
        public Qty myMethod(InventSum _inventSum, FormDataSource _ds)
        {
            InventTrans inventTrans;
            InventDim inventDim;
    
            Common common = formJoinedRecord(_inventSum, _ds);
    
            if(common.TableId == tableNum(InventDim))
            {
                inventDim = common as InventDim;
            }
    
            if(inventDim.InventLocationId)
            {
                return 99;
            }
    
            return 0;
        }
    
    }

    The requirement is that the display is to show a value of 99 if the 'Location' storage dimension is enabled and not empty for the row.
    I have the same logic in AX12 and there it works without any problem. I'm trying to get it into D365, but with no results.


    Could you please help me?

  • Martin Dráb Profile Picture
    Martin Dráb 230,868 Most Valuable Professional on at
    RE: How to check if a column is visible?

    Try iterating child controls of the grid and check if those user controls are there.

    for (int i = 1; i <= grid.controlCount(); i  )
    {
    	var control = grid.controlNum(i);
    }

    If it includes the control you're interested in, you'll just add code checking the particular table/field ID.

    I believe I even used it in one customization, but I'm not 100% sure.

  • Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    RE: How to check if a column is visible?

    Hi, The controls added by personalization are added as 'SysGen_', you can right click on form controls and check the control name. All existing fields by standard will have some meaningful control name.

    Also, if you can see Standard View in form then no new column added from UI, If there is any field added by personalization then user has to save the View and publish it if required for other users.

    I don't think its possible to check from code if field added via personalization exists in form grid.

  • Shooowtek Profile Picture
    Shooowtek 737 on at
    RE: How to check if a column is visible?

    I was more thinking of checking if a specific column has been added to the grid view.

    I want to add some logic depending on whether the column is visible or not....

  • Anton Venter Profile Picture
    Anton Venter 19,493 Super User 2025 Season 1 on at
    RE: How to check if a column is visible?

    From the top of my head and without checking in the application: have you tried by checking the number of columns in the grid? If you know how many columns there are to start with, then you can see if the user has added any columns.

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,031 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,868 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans