An editable field on a non-editable form

tinoruijstinoruijs Member Posts: 1,226
edited 2008-12-03 in NAV Tips & Tricks
Today I 'discovered' a nice litte trick. Thought I'd share it with you.

It was necessary to have an editable field on a non-editable form.

In the OnAfterGetCurrRecord on the form there is the following code:
CurrForm.EDITABLE(status = status::open);

So if status is released the form is non-editable.
But 1 field still has to be editable...

In the OnActivate of the field I put:
CurrForm.EDITABLE(TRUE);

In the OnDeActivate of the field I put:
CurrForm.EDITABLE(status = status::open);

Simple. But effictive.

Tino Ruijs
Microsoft Dynamics NAV specialist

Comments

  • ar4ijsar4ijs Member Posts: 24
    Is it for List or Card form ?
  • tinoruijstinoruijs Member Posts: 1,226
    ar4ijs wrote:
    Is it for List or Card form ?

    I used it on a Card- and Subform. So List-form will work too.

    Tino Ruijs
    Microsoft Dynamics NAV specialist
  • SavatageSavatage Member Posts: 7,142
    It's funny, never thought I would need this before.

    Then I see the post and guess what a week later it's needed.

    Thanks.
  • ajhvdbajhvdb Member Posts: 672
    This looks good.

    Problem with activate and de-activate events in NAV, they get triggered when you don't expect it.
  • SavatageSavatage Member Posts: 7,142
    Great for Booleans since no other entry is needed other than a click

    OnActivate()
    CurrForm.EDITABLE(TRUE);

    OnDeactivate()
    CurrForm.EDITABLE(FALSE);
  • tinoruijstinoruijs Member Posts: 1,226
    Savatage wrote:
    Great for Booleans since no other entry is needed other than a click

    OnActivate()
    CurrForm.EDITABLE(TRUE);

    OnDeactivate()
    CurrForm.EDITABLE(FALSE);

    That's right!
    8)

    Tino Ruijs
    Microsoft Dynamics NAV specialist
  • Stijn_MattheusStijn_Mattheus Member Posts: 2
    This is a good solution but i have experienced some problems with it.
    Sometimes i get an error message "<table name> cannot be changed in this form" while using it.

    Maybe there's something else i've got wrong, just pointing it out...
  • tinoruijstinoruijs Member Posts: 1,226
    This is a good solution but i have experienced some problems with it.
    Sometimes i get an error message "<table name> cannot be changed in this form" while using it.

    Maybe there's something else i've got wrong, just pointing it out...

    Probably you're changing the current record through code and you'll need a CurrForm.UPDATE when you return on the form.

    Tino Ruijs
    Microsoft Dynamics NAV specialist
  • SavatageSavatage Member Posts: 7,142
    Depending on the license there are tables you cannot change regardless of it being set to editable yes or no. like ledger entries n such.

    for example,you need the item list to be non-editabl else people can be changing things by accident. but if you wanted to be able to change the blocked field only in the list then you might use such a code.
  • pranav-joshipranav-joshi Member Posts: 46
    It's good, if we want only some filed to be editable on the form we can do it by making EDITABLE Property True for that fields and for others it will be false, its is simplest way if it is available then why to write code if objective is achived by using property =P~



    Pranav

    Pranav Joshi
    MS Dynamics NAV Consultant
    SBS Group Desert Mountain (Formerly Silverware Inc.)
  • Miklos_HollenderMiklos_Hollender Member Posts: 1,598
    Remember to turn off InsertAllowed and DeleteAllowed AND remember to set any other field noneditable that you add to the form and it will be OK.
Sign In or Register to comment.