Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

Setting a button's text and visibility in a grid based on conditions

(0) ShareShare
ReportReport
Posted on by 15

Hello,

I'm trying to put a column on a form grid that acts like a button (either it is a button, or is clickable text), where the buttoncontrol.text() and the buttoncontrol.visible() will change according to certain conditions. For example: in Row 1 condition A is true, button.visible = false and button.text = 'empty string'. In Row 2 condition A is false, set button.visible = true and button.text = 'true'.

The data source on the form/grid is a View generated from a query. "Condition A" is a computed column on the view, ie "if Condition A, set button text = 'lorem ipsum' and visible = true".

pastedimage1666196043908v2.png

How would you go about doing something like this? Is it possible to create a method call/override in the form to loop through the rows/buttons and check conditions per row, then set visible/text on a button, per row? 

It needs to be clickable because clicking the enabled/visible button takes args from the row and links to another form based on those args. I have that bit working but I can't for the life of me figure out how to set text on a button per row, based on args from that row. 

This is on a net new/custom form, view, and query.

  • GirishS Profile Picture
    GirishS 27,816 Super User 2024 Season 1 on at
    RE: Setting a button's text and visibility in a grid based on conditions

    What about edit method?  

    Refer to the below URL for edit method. Check whether edit method can suit your scenario.

    https://dynamics365musings.com/d365-edit-method/

    Thanks,

    Girish S.

  • Martin Dráb Profile Picture
    Martin Dráb 230,340 Most Valuable Professional on at
    RE: Setting a button's text and visibility in a grid based on conditions

    You can't set visibility on individual cells in a grid. You can only hide the whole column, which clearly isn't what you want. But you can use empty values in those cells.

    Regarding the button, why you can't you follow F&O form patterns and place the button in a toolbar above the grid? Please check out Toolbar and List subpattern.

  • RE: Setting a button's text and visibility in a grid based on conditions

    If you are adding a view as datasource to a form you don't have access to CRUD operations.

    I don't want to CUD, but I do wish to Read - ie Read the value of a field in a record and set the text of a form control. Is that not possible?

    My suggestion will be creating a display method on the form instead of controls

    I have a display method, as shown in the screenshot above. The 'Coll Status' column is a display method. However, I don't think it's possible to make that display method a clickable button, which is what I'm trying to accomplish. Either make the display method clickable, or find out how to make a clickable button update according to the applicable record. 

    Also display method will view only data you cannot edit it.

    i don't want to edit the data, only Read the data and set the button.text() based on the Read data. 

  • Suggested answer
    GirishS Profile Picture
    GirishS 27,816 Super User 2024 Season 1 on at
    RE: Setting a button's text and visibility in a grid based on conditions

    If you are adding a view as datasource to a form you don't have access to CRUD operations.

    My suggestion will be creating a display method on the form instead of controls.

    Also display method will view only data you cannot edit it.

    Thanks,

    Girish S.

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,602 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,340 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans