Overwrite value on method created formRealControl

Here is how I am trying to update a value to be a custom value from the CostingVersion Table. This control does not contain a datasource. It is a method that runs off the form BOMCalcDialog. It is getting the correct information but when I test the code. It doesn’t change to what is expected. It shows 1 not 5 which is what variable “qty” equals. Why isn’t it committing the change and displaying 5 on the form instead?

[FormEventHandler(formStr(BOMCalcDialog), FormEventType::Initialized)]
    public static void BOMCalcDialog_OnInitialized(xFormRun sender, FormEventArgs e)
    {
        FormRealControl itemqty = sender.design().controlName("itemQty");
        itemqty.autoDeclaration(true);
        FormStringControl costVer = sender.design().controlName("VersionId");
        str version = costVer.valueStr();
        CostingVersion costingVersion;
        select * from costingVersion
            where costingVersion.VersionId == version;
        ProductQuantity qty = costingVersion.MJMChargesQty;
        itemqty.realValue(qty);
    }

Doesn’t it simply mean that the value is overwritten later?

By the way, you can greatly simplify your code with CoC. You should be able to write something like this:

void init()
{
    next init();

    itemQty.realValue(CostingVersion::find(versionId.text()).MJMChargesQty);
}

This field was still not overwritten using the CoC code and it was retrieving the correct information but RealValue stills shows 1 in the debugger.

You missed my point.

My question is whether the value isn’t overwritten later. It’s a suggestion of what you should debug.

I don’t claim that using CoC will change the behavior of your code. On the contrary - I showed you that you can achieve the same behavior with much less code.