How hide a field for a selected user

kmkaotkmkaot Member Posts: 261
Dear Friends

Please suggest me..

I want hide unit cost values for some users. will suggest me what code I should write

usersetup.GET(USERID);
if usersetup.costhide then
begin
// I want help her
unit cost visible false
//======
end;

Please help
warm regards
KMK

Answers

  • kmkaotkmkaot Member Posts: 261
    I think this will not work.
    I wrote code NAV 2009 like this

    ====================
    if UserId = 'X' then
    "Unit Cost".VISIBLE :false;
    ====================

    I want to know same kind of code

    Please advice..

    warm Regards
    KMK
  • mohana_cse06mohana_cse06 Member Posts: 5,503
  • ishwarsharma016ishwarsharma016 Member Posts: 50
    You must take help from a developer to achieve your desired output. :smile:
    Thanks,
    Ishwar Sharma

    My Blogs: Dynamics Community Blog | Blogspot
    Connect: Google + | Twitter
  • kmkaotkmkaot Member Posts: 261
    I am looking for a developer for my Dubai operations.
  • RockWithNAVRockWithNAV Member Posts: 1,139
    Kamkpt,

    This Code will never work

    "Unit Cost".VISIBLE :false;

    If its classic client then you need to write code on the form like this.

    CurrForm."Unit Cost".VISIBLE(FALSE);


  • rsaritzkyrsaritzky Member Posts: 469
    edited 2016-10-19
    In RTC in 2009 and in 2013 and later, the VISIBLE property can be controlled by a variable:

    1. Open the page in the Development Environment
    2. Create a global variable, type Boolean, e.g. UnitCostHidden
    3. Select the "Unit Cost" field and view the Properties
    4. In the "Visible" property, insert the name of your new variable preceded by NOT, e.g. NOT UnitCostHidden

    Since the default of a Boolean variable is FALSE, the default value will be TRUE (i.e. NOT (False)), so the default of the field will be visible.

    Then, in your code:
    ====================
    if UserId = 'X' then
    UnitCostHidden := TRUE;
    ====================

    Now, when the field is displayed, the VISIBLE property will be (NOT (True)) = FALSE, so the field will be hidden.

    Your code to set the UnitCostHidden should be in the OnAfterGetCurrRecord OnOpenPage trigger.

    Good luck!

    Ron

    Ron
  • KishormKishorm Member Posts: 921
    Regarding the solution provided by @rsaritzky - you'll also need to make sure that you set the IncludeInDataset property to Yes on your Boolean variable (UnitCostHidden)
  • kmkaotkmkaot Member Posts: 261
    still showing


    usersetup.GET(USERID);
    IF usersetup."Hide Unit Cost" THEN
    UnitCostHidden := TRUE;
  • rsaritzkyrsaritzky Member Posts: 469
    Kishorm wrote: »
    Regarding the solution provided by @rsaritzky - you'll also need to make sure that you set the IncludeInDataset property to Yes on your Boolean variable (UnitCostHidden)

    Hi Kishorm,

    Thank you for pointing this out - it is something I forgot to point out.
    Ron
  • rsaritzkyrsaritzky Member Posts: 469
    KMK,

    I am sorry for giving you a little incorrect information. Being pretty sure that this should work, I tested it myself, and you are correct - it does not work.

    You must put the check for the UserID's permissions in the OnOpenPage trigger, NOT the OnafterGetRecord or OnAfterGetCurrRecord trigger. If you put it there, it should work. I will try to find an MSDN reference on when this property for the field is evaluated.

    Ron
    Ron
  • rsaritzkyrsaritzky Member Posts: 469
    OK, here's the full explanation according to MSDN:

    https://msdn.microsoft.com/en-us/library/dd355373(v=nav.90).aspx

    It says (among other things):

    1. Using a variable for field and action controls requires that the variable be resolved by the OnInit Trigger or OnOpenPage Trigger.

    2. The dynamic options are only possible for group and part controls.

    SO, if you have a need to dynamically change the hidden property on a field as you move from record-to-record, you need to put that field into a group on the page, then assign the "hidden" variable to the group. I test this and it then works if you put the setting of the hidden variable in the OnAfterGetRecord or OnAfterGetCurrRecord trigger.

    In your case, since the hidden property is based on the User, you can put your code in the OnOpenPage trigger and it should work for you.

    Once again, I apologize for misleading you a bit. I DID try <grin>.

    Ron

    Ron
  • kmkaotkmkaot Member Posts: 261
    thanks
  • kmkaotkmkaot Member Posts: 261
    Very nice
    thanks you
    it is working
Sign In or Register to comment.