You cannot make any changes to the database until a trans...

bhalpin
Member Posts: 309
Hi.
The full error is:
You cannot make any changes to the database until a transaction has been started
Here is the situation:
Customer's Item table is full. Yup, full. There's a whole bunch of custom fields so there's no room for what I need to add.
I have though of disabling some fields that I know they will never use, but I think that's bound to be a dsaster when some code down the line references a field I've disabled. (I don't want to take that phone call!)
So, my plan is to create an item 'companion' table where I can add all the fields I want to. That's done. And, on the item card I've added a new tab, and on it I've placed a subform for the new table. That works.
Now the problem is keeping the subform 'companion' record synchronized with the item the main form is on. This would involve creating the companion record 'on demand' as the user moves from item record to item record.
Naively I put the following code in the OnAfterGetRecord() trigger:
I've read posts here on this error and one suggestion was to put code like that in the item record and call that from the form trigger. Nope, same error.
So, I'm wondering if there is any way of achieving this functionality.
My alternative is to do a quick report to create companion records for all the existing items, and create new companion record from the OnInsert() trigger of the item table. (I've tried it, and it works.)
But, for some reason I prefer the first method - if it's possible.
Thanks in advance for any suggestions!
The full error is:
You cannot make any changes to the database until a transaction has been started
Here is the situation:
Customer's Item table is full. Yup, full. There's a whole bunch of custom fields so there's no room for what I need to add.
I have though of disabling some fields that I know they will never use, but I think that's bound to be a dsaster when some code down the line references a field I've disabled. (I don't want to take that phone call!)
So, my plan is to create an item 'companion' table where I can add all the fields I want to. That's done. And, on the item card I've added a new tab, and on it I've placed a subform for the new table. That works.
Now the problem is keeping the subform 'companion' record synchronized with the item the main form is on. This would involve creating the companion record 'on demand' as the user moves from item record to item record.
Naively I put the following code in the OnAfterGetRecord() trigger:
IF NOT ItemCompanionRecord.GET("No.") THEN BEGIN ItemCompanionRecord.INIT; ItemCompanionRecord."No." := "No."; ItemCompanionRecord.INSERT; END;When I click on Next Record - *Poof* -I get the error above. Duh, of course, I've seen this before. :oops:
I've read posts here on this error and one suggestion was to put code like that in the item record and call that from the form trigger. Nope, same error.
So, I'm wondering if there is any way of achieving this functionality.
My alternative is to do a quick report to create companion records for all the existing items, and create new companion record from the OnInsert() trigger of the item table. (I've tried it, and it works.)
But, for some reason I prefer the first method - if it's possible.
Thanks in advance for any suggestions!
0
Answers
-
I admit I read that post quickly but can I assume the key for the companion table is also "No."
2nd I will assume you set up the SubFormID & SubFormLink properly?
3rd I will assume you want the extra item data to be entered into a created companion table form?0 -
Hi.
Yes, you're correct on all three counts.
Also, I should have added that this is NAV 4.0 SP3.0 -
If you are using a subform and have the link setup correctly you shouldnt need to create the companion record in code. It will create when the user enters data on the first non-key field of the companion subform.
If you always want a companion item record then I would suggest that you auto create all of the existing items new companion records through a report and then in the on insert trigger of the table you create the companion and in on delete trigger of the table you delete the companion. that way the existing items will have a companion record and all new items will have a record.0 -
If you are using a subform and have the link setup correctly you shouldnt need to create the companion record in code. It will create when the user enters data on the first non-key field of the companion subform.
Wow, that rings a bell - I'll look into that.
Thanks!!!
Bob0 -
That's why I had to ask if you set that up correctly 8)0
-
Hi.
Maybe I spoke too soon and the subform isn't configured quite right.
Fo now, I went with the option of simply creating all the 'companion' records with a report. All is well exceopt for one thing.
On the item card, when on an Item field, I PgUp/PgDn (Rec Prev/Rec Next), the 'companion record displayed in the subform stays in synch just fine.
But if I make a field on the companion subform active and PgUp/PgDn, the 'companion' record moves independantly of the 'main' item record.
How do I either disable the record movement from within the subform, or make the main form 'follow' the subform. (I don't care whitch, as long as they stay synchronized.)
BTW: Subform: SourceTaleRecord & SourceTableVew props are <undefined> - that looked like where I should focus, but haven't found the 'magic'.
Thanks!!!!!0 -
Got it - I just put EXIT; in the OnNextRecord trigger and now PgUp/PgDn is disabled in the sub-form.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