Quantity for items per location not updated.

liizzliizz Posts: 135Member
Hello all,

I have added a field Inventory on the Purchase Line of my Purchase Order which check the Quantity for items per location defined.

I have added a Flowfield on the field Inventory on the table: Sum("Item Ledger Entry".Quantity WHERE (Item No.=FIELD(No.),Location Code=FIELD(Location Code)))..

For e.g: I have chosen Item A and Location Code Green which returns a Quantity of 2 in my Inventory field..
Now, I have change Location Code to White which has a zero quantity but it is giving 2 as quantity.
It is not being updated accordingly. I have to click on the Sales Header part for it to update.

How can I refresh the Quantity without clicking on the form?

Also I have used: CurrForm.UPDATECONTROLS on the Location Code- OnValidate

Thanks
Liizz

Comments

  • nvermanverma Posts: 386Member
    Similar issue has been discussed previously. :)

    Please Search the form.
  • DenSterDenSter Posts: 8,049Member
    Add a CALCFIELD command for the inventory field to the OnValidate trigger of the Item number and the Location code fields, in the TABLE NOT THE FORM.

    You need to stop programming forms for data validation. The form triggers are for display purposes only. Data validation should be programmed on the table level.
  • liizzliizz Posts: 135Member
    DenSter wrote:
    You need to stop programming forms for data validation. The form triggers are for display purposes only

    I have not understand your point. Can you please explain me in some details.

    Thanks
    Liizz
  • nvermanverma Posts: 386Member
    You need to stop programming forms for data validation. The form triggers are for display purposes only
    All your data processing/calculations should be done on the table. Forms are just used to display data (Therefore, as a rule of thumb, you should not do any calculations/validation in the form itself)
  • DenSterDenSter Posts: 8,049Member
    liizz wrote:
    Can you please explain me in some details.
    What I think is happening, is that you open the form in design mode, and you program this code into the OnValidate trigger of the field on the Form object. Instead, you need to figure out which table the form is showing, and program the validation logic into the OnValidate trigger of the field in the TABLE object instead.
  • ChinmoyChinmoy Posts: 359Member
    Also, I fail to understand why you need to add the Inventory field in the Purchase Line table? If you need to display the stock balance of an item in combination to it's location, you can calculate the Inventory by taking a record variable for Item and write a code to filter and then issue a CalcFields for Inventory field and get the balance in a variable. Then display the variable in the Purchase Line with a calculated field.

    Chn
  • dansdans Posts: 142Member
    liizz wrote:
    Also I have used: CurrForm.UPDATECONTROLS on the Location Code- OnValidate
    Liizz

    Try using CurrForm.UPDATE
    Microsoft Certified IT Professional for Microsoft Dynamics NAV

    Just a happy frood who knows where his towel is
Sign In or Register to comment.