Update Form from SubForm

I have a form Customer with a field Has Comment(boolean) and a button Comments that opens another form where i can put comments in. When i close the comments form, Has Comments field in my Customer form should be updated but i cant find a way to do it i have tried different triggers on my Customer form using CurrForm.UPDATE but i cant seem get it to work. The only way Has Comments is updated if i open the comment form again.

Code behind Comments button:
CurrForm.SETSELECTIONFILTER(Customer);
CheckComments.SetCommentForCustomer(Customer);



And this is the code that i have in my CodeUnit
IF pCustomer.FINDSET(TRUE,FALSE) THEN REPEAT
  Comments.RESET;
  Comments.SETRANGE(TableLink,pCustomer.Customer);
  Comments.SETFILTER(Comment, '<>%1','');
  IF Comments.FINDFIRST THEN
    pExecise3Customer.HasComment := TRUE
  ELSE
    pCustomer.HasComment := FALSE;
    pCustomer.MODIFY;
UNTIL pCustomer.NEXT = 0;

Best Answer

  • alex88alex88 Member Posts: 4
    Answer ✓
    I found the problem. When i press my Comment button it does
    CurrForm.SETSELECTIONFILTER(Customer);
    CheckComments.SetCommentForCustomer(Customer);
    

    The problem with that is that is that it was running my CheckComment codeunit before i even made any changes. I just moved my codeUnit to OnCloseForm trigger so the codeunit runs after i made the changes and closed the form.

Answers

  • KlappspatenKlappspaten Member Posts: 22
    Have you set the UpdatePropagation property to 'Both'?

    For more info check the Microsoft Docs
  • alex88alex88 Member Posts: 4
    I'm using Dynamiv Nav 2009 i've read that UpdatePropagation was added in Nav 2016? Or am i wrong? I can't find it anywhere.
  • KlappspatenKlappspaten Member Posts: 22
    alex88 wrote: »
    I'm using Dynamiv Nav 2009 i've read that UpdatePropagation was added in Nav 2016? Or am i wrong? I can't find it anywhere.

    Yes, you are right. With NAV 2009 you can only achive this by using some tricky functions. I have found this blog article for example.

    https://dynamicsuser.net/nav/b/mark_brummel/posts/tip-25-update-header-page-from-the-line-page
  • alex88alex88 Member Posts: 4
    Answer ✓
    I found the problem. When i press my Comment button it does
    CurrForm.SETSELECTIONFILTER(Customer);
    CheckComments.SetCommentForCustomer(Customer);
    

    The problem with that is that is that it was running my CheckComment codeunit before i even made any changes. I just moved my codeUnit to OnCloseForm trigger so the codeunit runs after i made the changes and closed the form.
Sign In or Register to comment.