In one of my customizations, I needed to display a progress bar directly inside a grid column. Since D365FO doesn't provide a native progress bar control for grid cells, I created a lightweight solution using a display method and Unicode characters.
Creating the Progress Bar
- Calculate the completion percentage.
- Convert the percentage into a fixed number of blocks.
- Display filled and empty Unicode characters to represent the progress.
- Append the numeric percentage for better readability.
[SysClientCacheDataMethodAttribute(true)] // Optimizes grid performance
public display str progressBarField()
{
str progressBar = "";
int percentage;
int filledBlocks;
int emptyBlocks;
int totalBlocks = 10;
RandomGenerate randomGenerate = RandomGenerate::construct();
percentage = randomGenerate.randomInt(0,100);
filledBlocks = real2int(round((percentage / 100) * totalBlocks, 1));
emptyBlocks = totalBlocks - filledBlocks;
// Unicode characters:
// █ (U+2588) - Filled block
// ░ (U+2591) - Empty block
progressBar = strRep("█", filledBlocks) + strRep("░", emptyBlocks);
// Append text percentage for readability
return progressBar + " " + int2Str(real2int(percentage)) + "%";
}
Improving the Visual Appearance
To make the progress bar stand out even more, I also customized the field's appearance by changing its background and text colors using the displayOption() method.
[DataSource]
class ExceptionLog
{
public void displayOption(Common _record, FormRowDisplayOption _option)
{
//red color
_option.backColor(WinAPI::RGB2int(170, 26, 44));
//white color
_option.textColor(WinAPI::RGB2int(255, 255, 255));
FormControlId BarControlId = this.formRun().controlId(formControlStr(ExceptionLog, ProgressBar));
_option.affectedElementsByControl(BarControlId);
super(_record, _option);
}
}
This allows the progress bar field to have a custom background color (red in this example) and white text, making it much more noticeable within the grid.
Limitation
One limitation of this approach is related to the way Dynamics 365 Finance & Operations handles row and field highlighting. If the grid record is highlighted by the application, the standard highlighting logic overrides the colors defined in the displayOption() method. In such cases, the background color and text color applied will not be displayed because the framework applies its own visual indication for the highlighted record.
Result