qty must be positive

in my inventjournaltransqty form datasource have field qty

I have to show if the field value negative we have to show the error and do not insert that value

which code I have to write in qty field modified

Hi hareesh,

Put this validation in the InventJournalTrans->Qty->Modified method. put this before call super().

if(this.getValue()<0)

throw error(strFmt("%1 - Value is Negative",this.getValue()));

Use validate() instead of modified() and show a warning and return false if a validation fails.

I have written that code … but again qty accepts the -ve value

Sorry, I can’t comment your code unless you show it.

Please always provide as much information as possible - it will increase your chance to get a helpful answer.

You can write in field validate method as below

if(yourTable.Value < 0)

ret = checkFailed(“The value should not be negative.”);

else

ret = super();

Thanks & Regards,

Britto John Baskar.A

It’s better to run kernel validations (super()) before custom validations. Therefore the usual implementation looks like this:

boolean ret = super();

if (ret)
{
    if (yourTable.Value < 0)
    {
        ret = checkFailed(...);
    }
}
return ret;

Hi ,

try with below code

public boolean validate()

{

boolean ret;

if(yourTable.yourTableField < 0)

ret = checkFailed(“The value should not be negative.”);

else

ret = super();

return ret;

}

Thanks & Regards,

Britto John Baskar.A