How to check if Rec IS TEMPORARY

Eugene
Member Posts: 309
i need to write-protect a table but still want to allow writing to temporary version of the table
is there a way in table's code to check if the instance of a table is temporary ?
is there a way in table's code to check if the instance of a table is temporary ?
0
Comments
-
If you are working with temp table, in generally you are not using VALIDATE or INSERT(True) etc. (Why? Because if yes and you will modify another data within the triggers, you can have BIG problem...).0
-
No but good Naming Conventions will help, look at the Standard Code, in the posting units you will see, TempDocDim, TempSalesLine etc:, these have thier property set to temporary.
If you make a mistake, and do a un-condition delete, on a live table #-o
So always test in a development server, never on the live, and check all, data (view all if you have filters), not just the couple of records you inserted. :whistle:Analyst Developer with over 17 years Navision, Contract Status - Busy
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com0 -
Actually i has found a way :
function IsTemporary() : Boolean;
BEGIN
RecRef.GETTABLE(Rec);
EXIT(RecRef.NUMBER>=1000000000);
END;
it seems that temporary tables numbers are >=1000000000
But i must thank kine for a very important tip that actually solved my problem"If you are working with temp table, in generally you are not using VALIDATE or INSERT(True) etc."1 -
It's not always that simple Eugene
. You should at least check what happens in the OnInsert trigger, so you can duplicate the logic if that is needed, or write your own logic. Like for instance numbering series. For sure you don't want to mess up numbering series while in a temp record, so you'll hae to write your own logic to create a new number. There may be descriptions from other tables that are populated in the Insert trigger. Just changing the parameter from TRUE to FALSE is not always the complete solution.
0 -
Functionality has changed beginning with NAV 2009. You should no longer rely on a temporary Table number anymore. In fact, it does not work anymore. But Microsoft has added a property ISTEMPORARY.
With Versions 2009 up to 2015, you still have to convert your Record to a RecordRef. Unfortunately this useful property is available for a Record variable only starting from NAV 2016.0 -
best regards
Franz Kalchmair, MVP
Alias: Jonathan Archer
please like / agree / verify my answer, if it was helpful for you. thx.
Blog: http://moxie4nav.wordpress.com/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