Update Field of table w.r.t. other field of same table

sachinjadhav11
Member Posts: 4
Is there any way to update fields of table with respect to other fields of same table in Dynamics NAV?
0
Comments
-
What is your need?
You usually do this by adding code to the OnValidate trigger or create ProcessingOnly Report.0 -
It depends on wich table you want to update and from what table are you taken the values.
If those are some customezid fields, then you'll need to write some code to do it.
Salut!Laura Nicolàs
Author of the book Implementing Dynamics NAV 2013
Cursos Dynamics NAV (spanish) : http://clipdynamics.com/ - A new lesson released every day.0 -
I agree, you have to do it in code.
If you want to let the user update som field with respect to some other field you could do a special report for this. I created a report for updateing Sales Orders, Sales Lines and two of our custome tables calld Distribution Flow Header and Destination Line, that we hav in our system.
I have attached an screen dump of the request form to this post.
The user uses the data item tabs to filter the table/tables he or she wish to update. In the option tab the user specifies the field that shall be updated and the new value of the field.
To make the report more intuitive the user is also able to enter the old value of the field that is updated. This is tha same as seting a filter on the same field in corresponding data item tab.
Let's say you wish to update the sales person code on all sales orders for a certain customer because the customer is asigned to a new sales person. Then you would fire up the report, set a filter on the Sales Customer No. field of the sales header data item tab. Then you chose to update the Salesperson Code on the Option tab and enter the new sales person code of the customer in the "New field value" text box. If you wish to leave any sales orders that have a manually set salesperson code untouched you would also specify the sales customers old sales person code in the "Old value" text box.
To get something like this working you need to be creative using RecordRef and FieldRef data types.
This kind of report is powerfull but also dangerous to use since there is always a risk of inadvertedly updating lots of records with incorrect values. Only users that know what they are doing should be alowed to use it and you shuld implement lots of checks, ability to preview before changeing and parheps some kind of undo functionality.
Also make sure that all fields that are updated are also validated since lots of fields have code in their OnVAlidate triggers that update yet more fields.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