Using registerOverrideMethod to get a lookup value dynamically

Hello,

I created a customized form and I have placed a string control and used registerOverrideMethod to control as lookup. The form works well if I choose a value from the drop-down but if I manually key in values in the control it automatically changed to the previous value which I selected using the drop down.

I am sharing the code,

/// <summary>
/// This method is used to initialize the dialog fields and  call the method events like modified.
/// </summary>
public void postBuild()
{
    super();

    contract        = this.dataContractObject();

    itemRelation    = this.bindInfo().getDialogField(contract, methodstr(KTI_SalesPriceAgreement_Contract, parmPriceDiscItemRelation));
    itemRelation.registerOverrideMethod(methodStr(FormStringControl,lookup),methodStr(KTI_SalesPriceAgreement_UIBuilder,itemLookup),this);//lookup to display the item details
    itemRelation.registerOverrideMethod(methodStr(FormStringControl,modified),methodStr(KTI_SalesPriceAgreement_UIBuilder,setTransactionCurrency),this);// use this method to recalculate the item cost when item is selected using drop down.

}

Where itemRelation is the dialogfield control.

public void setTransactionCurrency(FormStringControl _control)
{
    InventTable         inventTable;
    InventTableModule   inventTableModule;
    ItemId              itemId;
    Percent             localPercent;
    PriceBase           localPrice;
    real        calculatedPrice;

    ;


    itemId = itemRelation.value();
    itemRelation.value(itemId);
    //returns the sales price for the selected item
    if(price.value() == 3)//"Default sales price"
    {
        select * from inventTable where inventTable.ItemId == itemId
        join inventTableModule where inventTableModule.ItemId == itemId
        && inventTableModule.ModuleType == ModuleInventPurchSales::Sales;

        amountInCurrency.value(inventTableModule.Price);
    }

}

In the setTransactionCurrency I am assigned the control value, but it is automatically getting changed to the previous value.

It works fine if the user chooses the value from the dropdown the problem exists only if we type the values manually. But in the backend, if I debug the values are coming correctly what is been typed and it is getting updated correctly in the table also but in the front end, it shows the previous value.

Thanks.

Related
Recommended