Cancelling newly entered record on the form

Cem_KaraerCem_Karaer Member Posts: 281
Hi all,

I have a list form based on a table (TableA) with PK consisting of three fields. The list form's DelayedInsert property is true. One of the PK fields is hidden and filled by the virtue of RunFormLink property of its caller form (i.e. users get that form via other card form that is based on a table (TableB) that has a table related field {related to TableA}; forgive me for my unsufficient English :)). Users fills the second and third PK fields. But there must be a control while entering the third PK field. When the control fails, the user is confirmed whether to keep on. If the user refuses, then he/she himself/herself has to push the Esc key to clear out the third PK field and then push the F4 key to clear out the second PK field. If he/she doesn't push the Esc key then the confirmation is asked again. If he/she pushes the Esc key but not the F4 key then the first and second PK field is filled and the record is created with the third PK field empty.

I don't want to make the user to remember several keystores so I want to cancel out all the job he/she did by using code and returning him/her to his/her ( :) insufficient English) initial state. I tried clearing the record variable, going to the last record, reseting the record variable and other fantastic things but none of them worked! Should this code be written in the form or table? (I would prefer the table option)
Cem Karaer @ Pargesoft
Dynamics NAV Developer since 2005

Comments

  • kinekine Member Posts: 12,562
    You need to prevent the user to create the record with empty 3rd PK field - what about TESTFIELD(Field3) in the OnInsert trigger of the table?
    In this case, the user will not be able to create the record and will be forced to enter correct value or delete the record he/she started to create. This will be easiest way, other ways will be more complicated and non-standard.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Cem_KaraerCem_Karaer Member Posts: 281
    Using TESTFIELD is ok. I even used it! But the real problem is to make the program do in code what the user does when he/she hits F4 key.
    Cem Karaer @ Pargesoft
    Dynamics NAV Developer since 2005
  • kinekine Member Posts: 12,562
    You cannot do it easilly, because if there is error, you cannot react to this error by some code... Just learn the users to how to do it, it will be cheaper and application-wide and workng on 100%, than making some customization working on 80% correctly and only on one point in the application. You can make things to prevent users to get into this situations by helping them to select the correct value etc.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Cem_KaraerCem_Karaer Member Posts: 281
    Ok then users should be able learn how to use it. Thank you Kine
    Cem Karaer @ Pargesoft
    Dynamics NAV Developer since 2005
  • jversusjjversusj Member Posts: 489
    i recall reading a thread on here about using sendkeys and using that thread to do something similar in my system for a stand-alone little mod we added.

    you can basically programmatically send a F4 and Yes (to confirm) to NAV if a condition is met, effectively duplicating what happens when the user hits that key to delete a record - of course, i think the new version of NAV changed hotkeys, so you'd have to deal with that during upgrades (is the sendkey you programmed still doing what you want it to do).

    it sounds like in your situation, though, training may be the best approach.
    kind of fell into this...
  • kinekine Member Posts: 12,562
    Yes, you can use sendkeys, but the problem is that you need to use them "after" some error happend, and this is the base problem, you cannot react to some error with some C/AL code... 8)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.