Copy a field to another field on the same table

DarkHorse
Member Posts: 389
Hello, need put a flowfield field (field1) from a table as a key, but Navision doesn't let it. Then I think create a new field (field2) and copy the content from field1 to field2 and put field2 as a key, but there is no way. I put in OnValitade from field1 the following code:
table.CALCFIELDS(field1);
field2:=field1;
How can I do this?.
Thanks.
table.CALCFIELDS(field1);
field2:=field1;
How can I do this?.
Thanks.
0
Comments
-
Hi,
You should perhaps do this in the OnModify trigger
Albert0 -
Onvalidate trigger fires when the field is validated, CALCFIELDS does not validate the field.
the update of the field2 can be painful, as you have to maintain it also when a flowfield changes value...
you can update your field2 in onaftergetrecord trigger of a form, but before doing calculations, check if field2 is really <> from field1 to minimize performance issues0 -
The flowfield calculate his value during runtime. So you can't copy the value to the field2.
Only on a Form but this is ](*,) ](*,)
So, whats the reason why you need the field as keyfield?Do you make it right, it works too!0 -
anyway, you can use my method, but you are not sure that data is 100% updated, because if you use the new key somewhere else, the form is not run and the fields are not updated (you can for sure create a function in the form to calculate the fields and after use setcurrentkey, but it's not good at all [-X )0
-
Thank you all. In a form works perfectly!!, but by this way I can't make this field a key. Well, thanks again for reply.0
-
You don't have to just update the field on a timer or at random intervals.
Take the table that contains the field you want to sum (or do whatever with). When this table is modified update the value in the table that has the new key field in it.
You'll have to do a bulk load first to fill in the field for existing records. And you'll also have to be sure that the modify/insert trigger [MODIFY(TRUE)] is called instead of just MODIFY/INSERT.
Weigh your performance hit, which shouldn't be much, against how badly you need to sort on the column.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