Wednesday, September 26, 2018

Color Picker Control in Microsoft Dynamics 365 for Operations

Introduction

Microsoft Dynamics 365 for Finance and Operations provides many out-of-the-box controls, but even after covering a vast amount, some controls need to be implemented by our self. Among those controls is a Color picker control, which allows a user to select a color from a selection of approximate 16 million colors.


Solution

In this solution, we would be implementing a basic color picker control with the goal of looking up 16 million colors, and allowing a user to select a single one.

To start, we'd create a form with the following form control:


Note that we are using a FormIntControl to specify a color picker control. An alternative to this approach is to use FormStringControl instead.

Now we will override the lookup method on Color picker control, this would allow us to view the colors in a circular wheel when the drop down button on FormIntegerControl is clicked.

public class ColorPicker extends FormRun
{
    [Control("Integer")]
    public void lookup()
    {
        int color = this.value();
        color = ColorSelection::selectColor(this, color);
        this.value(color);
        this.backgroundColor(color);
    }
}

Finally, we would run the form to view the results as:


Conclusion

In this blog, we looked at creating a color picker control. Even though we didn't perform operations on it to control the amount of colors it can produce, or display a subset of colors to the user, but we got an overview of its working. This can be helpful in scenarios in which colors are important such as tint of a car or paint of the house at a particular portion.

No comments:

Post a Comment

Copying a Record using data() method in D365 for Operations

Introduction Data is an essential pillar of an Enterprise. Therefore, Microsoft Dynamics 365 for Finance and Operations provides various ...