Show/Hide field dynamically in page

catiamatos1991catiamatos1991 Member Posts: 158
edited 2019-03-26 in NAV Three Tier
Hi everyone, I create a new field in Sales Header table called "Vasilhame" and this field only will be display when I choose a specific Posting No Series. So my idea was to include this field in my page and set the Visible property to a new boolean var I've created called ShowVasilhame.

This var have the option "Include In Dataset" equals to true and now I need to validate the change of Posting no Series equals to a specific text like "MRVFA" then this field should appear in my page, else it may still hide.

I create a function also called SetVasilhameVisibility(Show) where
LOCAL SetVasilhameVisibility(Value : Boolean)
ShowVasilhame:=Value;

Other code...
OnInit()
SetVasilhameVisibility(FALSE);

IF "Posting No. Series"='MRVFA' THEN
  SetVasilhameVisibility(TRUE);

OnOpenPage()
IF "Posting No. Series"='MRVFA' THEN
  SetVasilhameVisibility(TRUE);

Posting No. Series - OnValidate()
IF "Posting No. Series"='MRVFA' THEN
  SetVasilhameVisibility(TRUE);

Posting No. Series - OnLookup(VAR Text : Text) : Boolean

Posting No. Series - OnDrillDown()

My problem is when I change the posting no series, because it stays visible and don't hide anymore...

Answers

  • krikikriki Member, Moderator Posts: 9,096
    [Topic moved from 'NAV/Navision Classic Client' forum to 'NAV Three Tier' forum]

    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • vanthanhvanthanh Member Posts: 23
    1. Try to assign visible property of your field is "ShownVasilhame"

    2. Update current page

    LOCAL SetVasilhameVisibility(Value : Boolean){

    ShowVasilhame:=Value;
    CurrPage.Update(false)
    }

    I hope it will work.
  • ACaignieACaignie Member Posts: 91
    If it is a card page, put your field in a separate group, and set the group visible or not.
  • catiamatos1991catiamatos1991 Member Posts: 158
    So I create a Group with the field Vasilhame inside and with the option visible equals to "ShowVasilhame". Then I add this code in OnValidate

    Posting No. Series - OnValidate()
    SetVasilhameVisibility("Posting No. Series"='MRVFA');

    And I've update my SetVasilhameVisibility function to

    SetVasilhameVisibility(Value : Boolean)
    MESSAGE('vasilhame %1 ',Value);
    ShowVasilhame:=Value;
    CurrPage.UPDATE(FALSE);

    But nothing changed.. The message is not being pop when I change the posting no series... any idea?

    I've also remove the code in onInit and onOpenPage to validate the posting series no..
  • vanthanhvanthanh Member Posts: 23
    @ACaignie is correct, you should be create sub-group, after that try to set visible this group.
  • catiamatos1991catiamatos1991 Member Posts: 158
    edited 2019-03-27
    vanthanh wrote: »
    @ACaignie is correct, you should be create sub-group, after that try to set visible this group.

    I've already done that but is not working... maybe should be on another event rather than onValidate in Posting No series? In my opinion the correct event should be onLookup. I try to put the code in onLookup but the problem is that the dropdown box with the list of posting no series is not shown.. Only the pop up is shown but nothing else happen

    Posting No. Series - OnLookup(VAR Text : Text) : Boolean
    MESSAGE('nLoookup');
    MESSAGE('test %1,',"Posting No. Series"='MRVFA');
    //SetVasilhameVisibility("Posting No. Series"='MRVFA');
    IF "Posting No. Series"='MRVFA' THEN
    ShowVasilhame:=TRUE;

    SetVasilhameVisibility(Value : Boolean)
    MESSAGE('begin %1',Value);

    ShowVasilhame:=Value;
    CurrPage.UPDATE(FALSE);


    The first and the second message is displayed but in my function SetVasilhameVisibility the message "begin" I put inside is not appearing.. I try to change my condition to a if but nothing.


Sign In or Register to comment.