How to conditionally cancel an F3 New Record???

GaryD
Member Posts: 66
Hello all, here's my problem. Let's say I have a sales order with 1 line with an item (line 10000) on it and 3 lines of extended description for that item on lines 20000, 30000 and 40000. The user is on line 30000 when he hits F3. Currently this will insert a line between 30000 and 40000, splitting up the extended text that was already on the form. So I want to not allow an insert if the Attached to Line No. field on the line the user is on has a non-zero value. I've tried generating an error in the OnNewRecord trigger but that closes out the entire form. Thanks for the help!
0
Answers
-
Try to check the condition in OnInsert on the table. There you can look at previous and next line and call Error if the inserted line is in position where you want to not allow to create it.0
-
Thanks Kine. That would work in a pinch but would not trigger until the record was saved so the user would get the new blank line inserted into the form, then start filling it out and only then would they get the message that they cannot insert at that point. It would be nice if I could prevent all of that and give them the message right after they hit F3.0
-
I am afraid that there will not be easy solution for this, because nearly every error called from form will close the form (except OnValidate and may be other triggers). But e.g. you can display some Icon on the line to show the users that attempt to insert the line will end with error to give them "early warning"... :whistle:0
-
Thanks again Kine. That gives me enough information to know what I Need to do. I appreciate your help.0
-
I don't know if it would work but how about forcing the line no to always be the last#
Perhaps some code guru's can clean this up - if it even works at all..
I would guess you need it on a "Line no." trigger.IF Status = Status::Open THEN BEGIN Salesline.RESET; Salesline.SETRANGE("Document Type",xRec."Document Type"); Salesline.SETRANGE("Document No.",xRec."Document No."); IF Salesline.FIND('+') THEN "Line No." := xRec."Line No."+ 10000; END; It's rough, but an idea
0 -
Thanks Savatage, but the users will sometimes want to insert a line at a certain point. And I can't determine if they really wanted to insert the line at that point or if they were on the wrong line when they hit F3, so I don't want to automatically set their line to be the last line. I went with Kine's suggestion and am using the records OnInsert to display an error that the user is on a line that can't be split.0
-
I have put the following code in the Sales Order subForm onInsertRecord to disallow users using F3 to add lines to EDI orders
IF SalesHeader."Order Source" = SalesHeader."Order Source"::EDI THEN BEGIN MESSAGE(Text65005); EXIT; END;
It displays the message then returns to the line F3 was pressed on.0 -
Dave_S wrote:I have put the following code in the Sales Order subForm onInsertRecord to disallow users using F3 to add lines to EDI orders
IF SalesHeader."Order Source" = SalesHeader."Order Source"::EDI THEN BEGIN MESSAGE(Text65005); EXIT; END;
It displays the message then returns to the line F3 was pressed on.
I will preffer to add code into OnInsert trigger of the table which will call error instead message... ;-)0 -
normally.. you can write code on validate and so on.. n even if u write code on these other conditions, it will work fine... if u have delayed insert property on... with delayed property on, and with some logical code, you can have ur problem resolved....0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions