General X++ Development

How do I refresh a datasource from an edit method?

Asked by Sunny Vasty· Aug 13, 2026· 1 answers

How do I refresh a datasource from an edit method?

SSunny Vasty75 reputation · answered Aug 13, 2026

If this is a form edit method, update the value and refresh only what you actually need.

X++
public edit str myEditMethod(boolean _set, str _value)
{
    if (_set)
    {
        // Save/update the value.

        MyTable_ds.reread();
        MyTable_ds.refresh();
    }

    return currentValue;
}

Be careful with executeQuery() inside an edit method. Rerunning the whole datasource can move the active record or make the UI feel strange.

If the edit method is on a table, it should not try to reach into a form datasource. Keep UI refresh logic on the form.