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

sachinjadhav11sachinjadhav11 Member Posts: 4
Is there any way to update fields of table with respect to other fields of same table in Dynamics NAV?

Comments

  • vaprogvaprog Member Posts: 1,139
    What is your need?
    You usually do this by adding code to the OnValidate trigger or create ProcessingOnly Report.
  • kitikkitik Member Posts: 230
    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.
  • mabl4367mabl4367 Member Posts: 143
    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.
Sign In or Register to comment.