Hi all,
There is a method to know if a Record variable is a Temporary Record?
My problem is I'am using a Sales Header Temporary record variable and i need different behavior in Record trigger.
eg.
OnInsert() (Trigger of Sales Header Table)
IF ISTEMPORARY THEN
do something
ELSE
do something else
Thanks
Steve
0
Answers
Perhaps you vcan explain a bit more of what you are trying to accomplish?
http://www.BiloBeauty.com
http://www.autismspeaks.org
In your code that fills the temporary table, set this new field to True.
Then you can query this field in the OnInsert-trigger:
1. You can add extra field to the table, Integer type, with Autoincrement=Yes. Autoincrement will work only in real table, so if your autoincrement field is 0 after insertion then you are in temporary record. Problem is that you do not know this in OnInsert trigger, as this trigger is launched before record is physically inserted into database, and physical insertion of record increments AutoIncement field..
2. You can open another table variable, pointing to real table, and try to read newly inserted record. If you succeed you are in real table, if not - temporary. Again - not in OnInsert I'm afraid...
Perhaps in OnInsert trigger you could try INSERT, then make your test, then DELETE current record. After finishing OnInsert trigger the record will be re-inserted. It should work however I've never tried this. And of course it is far from optimal as instead of one database insert you will have three physical insert-delete-insert operations...
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
for example u have a Temp.Record "A" and a real record "A". In the onmodify or validate(of some Fields) are other tables modified based on the record "A".
Now you modify(true) or Validate(somefield) your temp.record "A". what do you thin would be done ..... ;-)
Regards
RIS Plus, LLC
MVP - Business Apps
It depends on what version of NAV you use.
In 2009 you can use the property IsTemporary of the variabletype RecRef:
Is earlier versions you can test the tablenumber of the variabletype RecRef.
If you have a temporary record the number is higher than 2000100000:
Regards,
Object Manager
I think this is the best advise. If you get in the habit of calling triggers on temp tables, one day you will do it on a trigger you have not modified and things will go bad. Try to rethink what you are doing and do it differently.
I searched in Nav documentation (Nav 2009 Sp1) for a function like ISTEMPORARY, but I didn't see it.
This seem to be an undocumented RecordRef function.
Thanks to everybody.
Every time i post a questions in this forum I get back always very high quality answer in few hours.
I love this forum!!