Item No. fixed on a new Form

In a new Sales Line form, I create by default a Item No. = XPTO, with his description, unit price and quantity =1.

When I try to Post the sales, the result is Nothing to be Posted. To have sucsess I must zoom in No. field, bring the same Item = xpto and after that the posting is OK.

I have tryed this:

On the Form, on TextBox field No.

No. - OnValidate()
ShowShortcutDimCode(ShortcutDimCode);
GetItem(“No.”);

Item.TESTFIELD(“No.”);
Item.TESTFIELD(Blocked,FALSE);
Item.TESTFIELD(“Inventory Posting Group”);
Item.TESTFIELD(“Gen. Prod. Posting Group”);

Form - OnNewRecord(BelowxRec : Boolean)
//Type := xRec.Type;

CurrForm.UPDATECONTROLS;
“No.”:=‘xpto’;
GetItem(“No.”);
Quantity:=1;
Type:=Type::Item;

Prod_Linha.GET (“No.”);

Description:=Prod_Linha.Description;
“Unit Price”:=Prod_Linha.“Unit Price”;

GetItem(No : Code[10])
TESTFIELD(“No.”);
IF Prod_Linha.“No.” <> “No.” THEN
Prod_Linha.GET(“No.”);

hi Luana,

Seems to me that you have forgotten to validate the “No.” field by code. This will happen if you manually enter a value in the “No.” field. That’s why it does work when do that (manually).

Note

When entering data by means of code it is often usefull to try to mimic manual data entry, so as if a user is entering the data. you will find that various fields are populated automaticall due to validation code on fields that did get filled by the user.

In this perspective maybe the following posts might be of help to you:

  • Validating Data #1: User Input
  • Validating Data #3: Cascading VALIDATEs