Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

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);
}







*This post is locked for comments

  • 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
    Sohaib Cheema Profile Picture
    Sohaib Cheema 46,610 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);
    }
    


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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans