Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

Change record color in grid based on a display method

Posted on by Microsoft Employee

Hello all,

I am attempting to create a modification to the WHSReleaseToWarehouse form where the grid control changes the record to a color based on a condition. I will be overriding the displayOption method in the datasource of the form.

The condition I was hoping to use is based on a display method. As I follow through the pattern for changing grid record colors I found that display method fields does not work.

For instance the below code errors out in the compiler. With the error "The table WHSInventTransSumDim does not contain the field displayQtyLeftToReleaseDelta." This is because the WHSInventTrnasSumDim is actually datasource named WHSInventTransSumDimSO and the field displayQtyLeftToReleaseDelta is the display method.

Can anyone recommend a way to use the display method in my condition?
Do I need to go down the route of creating a temp table?

public void displayOption(Common _record, FormRowDisplayOption _options)
{
    WHSInventTransSumDim        whsInventTransSumDimLocal;
   
    
    
    whsInventTransSumDimLocal    = _record;
    if (whsInventTransSumDimLocal.displayQtyLeftToReleaseDelta >= 1)
    {
        _options.backColor(WinAPI::RGB2int(255,255,0));//yellow
    }
    super(_record, _options);
}







  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Change record color in grid based on a display method
    public void displayOption(Common _record, FormRowDisplayOption _options)
    {
        
        WHSInventTransSumDim       whsInventTransSumDimLocal;
        whsInventTransSumDimLocal    = _record as WHSInventTransSumDim;
        if (this.displayQtyLeftToReleaseDelta(whsInventTransSumDimLocal) > 0)
        {
            _options.backColor(WinAPI::RGB2int(255,255,0));//yellow
        }
        super(_record, _options);
    }


    Here is the fully working code for anyone's reference.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Change record color in grid based on a display method

    This did work. The record coloring still needs to be refined as the grid seems to be coloring more records than it should but I'll be able to move further. THANKS AGAIN Sohaib! I appreciate the response.

  • Verified answer
    sohaibcheema Profile Picture
    sohaibcheema 46,594 User Group Leader on at
    RE: Change record color in grid based on a display method

    Hi Keith,

    How about trying  like following?

    Note:  Make sure to write your method under WHSInventTransSumDimSO DataSource

    public void displayOption(Common _record, FormRowDisplayOption _options)
    {
       
        if (this.displayQtyLeftToReleaseDelta(WHSInventTransSumDimSO) >= 1)
        {
            _options.backColor(WinAPI::RGB2int(255,255,0));//yellow
        }
        super(_record, _options);
    }
    


Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,349 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,212 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans