Problem with code

mkpjsr
mkpjsr Member Posts: 587
Hi all,

I want to show the current inventory of items on Transfer Order form when the Item No is selected, so I have written the following code under OnValidate trigger of "Item NO" fileld:

globals i have used:
ItemRec->Record->Item
Inventory->Decimal

ItemRec.GET("Item No.");
// ItemRec.SETFILTER(ItemRec."Location Filter",'MAIN STORE');
ItemRec.CALCFIELDS(Inventory);
Inventory:=ItemRec.Inventory;

If the line contains one item then there is no issue but, if i am selecting another item then the value of inventory field is getting updated with the inventory of new item.

should i use array or something else to resolve this issue.

Can anybody suggest me the solution.

Answers

  • einsTeIn.NET
    einsTeIn.NET Member Posts: 1,050
    OnValidate of the table field or of the field control in the form?
    Maybe you should move your code to the OnAfterGetRecord trigger of the (sub)form.
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • mkpjsr
    mkpjsr Member Posts: 587
    OnValidate of the table field or of the field control in the form?
    Maybe you should move your code to the OnAfterGetRecord trigger of the (sub)form.


    thanx, its done
  • vijay_g
    vijay_g Member Posts: 884
    Maybe you should move your code to the OnAfterGetRecord trigger of the (sub)form.

    The scene looking like you must have written your code on OnAfterGetRecord trigger because you have used a variable to show inventory. whether it will be better if you add a field in table and write code on validate trigger of item no.
  • einsTeIn.NET
    einsTeIn.NET Member Posts: 1,050
    vijay_g wrote:
    whether it will be better if you add a field in table and write code on validate trigger of item no.
    Yes, I think that would be a better solution, but I assumed that mkpjsr doesn't have access to the table design. That's why I said "maybe" and I asked for which OnValidate trigger.
    "Money is likewise the greatest chance and the greatest scourge of mankind."