Options

Form Trigger : On Next record & On After Get Record

RachelSoonRachelSoon Member Posts: 202
Hi All,
I relaised that the Previous and Next button at the menu bar does not working properly if i carry out some functions at the form On Next Record trigger.

Eg :
At sales order (F42), i did a mes sage at the On Next Record. So, i will see the message when i click the next record button. However, the record will stay there and will not be able to browse others records anymore.

Please advise. As i need to do some update to others table when user browse the sales record.

Thank you.

Regards
Rachel

Comments

  • Options
    krikikriki Member, Moderator Posts: 9,090
    I didn't completely understand what you need.

    When you show a record, do you need data from another table?

    Are there fields on the form that can be changed by the user and these fields have to be written to the DB in another table?

    PS "OnNextRecord" and "OnFindRecord" triggers are used to manipulate the record that will be taken. In general only used if you have to show records in a temptable (Eg. F498)
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Options
    RachelSoonRachelSoon Member Posts: 202
    Hi Kriki,
    Thank you for replying.

    Well, i would like to know is if the Form triger On Next Record and On After Get Record are allow to have coding for modifying and delete record on other table.
    Say, i am in Sales order, when i go to next record, i would like to update a field in my customised table. Is that posibble?

    Thank you.

    Regards
    Rachel
  • Options
    krikikriki Member, Moderator Posts: 9,090
    The new value of the field in your customized table, comes from a field on the form, changed by the user?
    In that case it would be better to put it in the "OnAfterValidate"-Trigger of the field:
    CurrForm.SAVERECORD; // this is to save the T36-record in case it has been changed
    UpdateMyCustomizedTable(); // this is to save something in the customized table.
    In this way both tables are changed in 1 transaction. (in case both tables have been changed by the user).

    If it is something else you want to do, you need to explain me what exactly you want to do.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Options
    RachelSoonRachelSoon Member Posts: 202
    Hi Kriki,
    You have enlighted a lots.

    THank ya... i got what you mean.

    Rachel
  • Options
    DenSterDenSter Member Posts: 8,304
    I wouldn't put that kind of code on the form though, but in the OnModify of the sales header, or in the OnValidate of certain fields. The problem with putting code on the form is that the code only works on that particular form, when mostly you would want the code to work regardless of what process entered the value. By programming the table instead, it will work no matter what form is used to modify the data.
  • Options
    kinekine Member Posts: 12,562
    Your main problem is, that if you write something into OnNextRecord, you must perform the moving to the apropriate record yourself - it means, that there is no more standard moving procedure, which move the current record to the next record (you replaced it with your code). You must add something as:
      Exit(NEXT(Steps));
    

    to the end of the procdeure else the current record is still same...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.