Wednesday, December 28, 2016

Move the pointer to the first record on NAV form

Recently I was working on a modification where I have to display an item related information in a form, the information is always changing so we need to get the new data every time they open the form. For this scenario I have created a new table and new form . We have  set the form SourceTableTemporary  property to yes , since we need to get the data and insert into the table every time they open the form.

ItemInfoINIT;
ItemInfo."Item No." := ItemNo;
ItemInfo."Line No." := LineNo;
ItemInfo.Attribute := Attribute1;
ItemInfo.INSERT;

I have added a new function to execute on the open form trigger which will retrieve the data from another SQL Server and insert the data. Everything worked fine but when i open the form. the cursor was on the last record. I want the pointer to be on the first record, when i searched on the form if there is any property that i can use to set the pointer i have not found any default property which can be set.

The solution is very simple, you just need to add the following statement in OnOpenForm triggger after inserting all the records.

IF FINDFIRST THEN;

I hope this will save time for others and especially for those who are new to the NAV development.

Please leave your comments, feedback or any suggestions you have for me to improve my blog and also if you have any questions, feel free to post.

Share:

3 comments:

Anonymous said...

Thank you for this post, those tips are great.
What's different in my current situation is I don't want to alter the form I open as it is the contact list. Any idea on how to do the same on a form variable?

Rishi said...

Awesome!!!
Your blogs always really helpful, Keep post.

kiran deore said...

Awesome!!!
What a great post man..i was wasted my 3 hrs and finally got your blog..it works like charm..thanks man..