Inserting into Table With code

mo_x
Member Posts: 50
Hey,
I'm trying to insert a new sales Line programmatically. However, I'm a bit lost on where should the code be written. I tried on Onvalidate trigger for No field.
and Oninsert trigger. But neither of those two worked. I used setrange, init, and some fields, but nothing happened.
I'm trying to insert a new sales Line programmatically. However, I'm a bit lost on where should the code be written. I tried on Onvalidate trigger for No field.
and Oninsert trigger. But neither of those two worked. I used setrange, init, and some fields, but nothing happened.
0
Best Answer
-
automatically i think it isnt possible in a easy way but u can put the code in a button. you can use oninsert and onmodify in order to insert a new line and refresh the data on that new line (every time the record is modified manually or modify(true); ) but i think it is better doing it with a button
think about the consecuences of doing it in oninsert and onmodify triggers. Oninsert means in each new line created by the user (maybe program flow too) another line will be created.
More important, in onmodify trigger means that every modification will suposse an error or a modification of another line. (error if u cant save the objective line in a new field)Giving thanks is always wellcome5
Answers
-
Try it on a new report or codeunit. Report with an integer dataitem filtered by number = how many lines u want
document no., line no. document type insert
etc
etc
etc
modify;Giving thanks is always wellcome0 -
You right, i could try it on report. but i want to insert new sales line when creating sales order.
when salesline1 is created.
then automatically salesline2 should be inserted.
it should have the same values as salesline1, but only number should be different: For example:
no. 1000
no.1100 < new line.
0 -
automatically i think it isnt possible in a easy way but u can put the code in a button. you can use oninsert and onmodify in order to insert a new line and refresh the data on that new line (every time the record is modified manually or modify(true); ) but i think it is better doing it with a button
think about the consecuences of doing it in oninsert and onmodify triggers. Oninsert means in each new line created by the user (maybe program flow too) another line will be created.
More important, in onmodify trigger means that every modification will suposse an error or a modification of another line. (error if u cant save the objective line in a new field)Giving thanks is always wellcome5 -
but the data refresh only works if u can say what is the line objective. and that u can only know at the moment of creation.
Moreover u have to think that if u make automatically u can be modifying the functionality of the standard in ways u dont wantGiving thanks is always wellcome0 -
add a button in the subform, not in the main page. (put it in page/form 46 not in 42)Giving thanks is always wellcome0
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