Hello, I want help in developing control add in, where I enter value in business central and I get the colour in another field. So please suggest me the code for the control add in. what wrong am I doing??? Getting error when entering value in business central field - A DotNet variable has not been instantiated. Attempting to call SetColor in Page demo controladdin card: Color - OnValidate. Page demo controladdin card - 0 has to close.
controladdin ColorPreview
{
Scripts = 'Scripts/colorpreview.js';
StartupScript = 'Scripts/colorpreview.js';
RequestedHeight = 30;
RequestedWidth = 60;
//Events = OnSetColor(hexValue: Text);
Procedure SetColor(hexValue: Text);
}
-------------------------------------------------------------------------------------------------------
color preview js file------
document.addEventListener('DOMContentLoaded', function () {
var div = document.createElement('div');
div.id = 'color-preview';
div.style.width = '100%';
div.style.height = '100%';
div.style.border = '1px solid #ccc';
document.body.appendChild(div);
});
function SetColor(hexValue) {
var container = document.getElementById('color-preview');
if (container) {
container.style.backgroundColor = hexValue;
}
}
window.SetColor = SetColor;
===============================================================================================
page fields---
field(Color; Rec."Color Hex")
{
ApplicationArea = all;
ToolTip = 'Specifies the value of the Color field.', Comment = '%';
trigger OnValidate()
var
ColorPreview: ControlAddIn ColorPreview;
begin
ColorPreview.SetColor(Rec."Color Hex");
end;
}
field(ColorPreviewControl; Rec."Color Hex")
{
ApplicationArea = All;
Editable = false;
ShowCaption = true;
//ControlAddIn = AKI_ColorPreview;
trigger OnValidate()
var
ColorPreview: ControlAddIn ColorPreview;
begin
ColorPreview.SetColor(Rec."Color Hex");
end;
}

Report
All responses (
Answers (