Question

I have modified a validate method of form control. On this control I'm typing the product name. In validate method I'm checking if this product name exists in the table. If it does not exists the error is thrown.

My issue is that after the error is thrown I want to clear control. Here is my code:

public boolean validate()
{
    InventTable inventTable;
    boolean ret = super();
    select inventTable
        where inventTable.nameAlias == this.text();    
    if (!inventTable.recid)
    {
        error("error");
        this.text("");
    }
    return ret;
}

this.text(""); does not work. So how can I clear the control? The control is a field from my datasource.

Was it helpful?

Solution

In validate methods you do not need to clear the field. The system does that for you when validate returns false.

So instead of this.text('')) just return false.

But I doubt that the idea of users entering the full name is really useful at all.

If you use NameAlias as an alternate item number an even easier option exist. Change the AliasFor property on the InventTable.NameAlias field to point to ItemId. When entering in an ItemId and you enter a NameAlias instead, it is translated to the corresponding item id by the AX run-time. This happens everywhere an item id is entered and validated.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top