Trigger row change in matrix form (subform)

asokasok Member Posts: 3
I need to do checking on sales line data inputted by the user and this should happen when user changes row on sales order subform and if qty > 0

By using on trigger OnAfterGetRecord I can see row change when changing already inserted rows and OnNewRecord when changing to newline. Problem is that OnAfterGetRecord loops through all records when opening a form or changing from subform to main form.

Now I am thinking of inserting boolean field on sales line table, that indicates if checking is made or not on the line. Is there any other way to do this?

Comments

  • kapamaroukapamarou Member Posts: 1,152
    You could use the OnAfterGetCurrRecord trigger. Also you could use the onValidate trigger on the table and compare Rec.Qty and xRec.Qty to check the previous value of the field on the record. There are many ways to do something depending an the exact result you are seeking. Could you provide some more details about what you want to check and when exactly? Maybe such a check could also be moved to the posting routine if you just want to prevent something specific to be blocked from posting. Where it is possible though, try keeping the code on the record (using insert,modify and validate triggers) and not on the form. It really helps...
  • asokasok Member Posts: 3
    Hi kapamarou,

    Thanks for your answer, requirements are these:
    Sales person inserts line than can be Bills of materials and sometimes they want to explode BOM and sometimes not, but we don't want them to forget to do this selection. We could explode the BOM after quantity is filled but they might do adjustments on price. We have made modification that takes main item price to BOM items in propotion.

    So we want to check is quantity changed or >0 if item is BOM when line changes and give dialog box to ask does user want to explode BOM.

    OnAfterGetCurrRecord works better for this purpose and problem that I now have, is case where user clicks directly to form header, then I can use OnDeactivateForm but this gives same xRec.Quantity as Rec.Quantity from the line where clicked to form header.
  • kapamaroukapamarou Member Posts: 1,152
    One fast thought is to use the OnActivate of the field, not the form, and then the onDeactivate of the field. Keep the first value in a temporary variable and compare it to the new value. It could work but it poses some other issues. For example: The value of the field is changed due to validation of another field...
Sign In or Register to comment.