How to write from Temp table to persistent table

Kenmu
Member Posts: 3
I have created a temp. table and read data from the jobqueues of multiple companies into it in order to gain easy access to our jobqueues. My issue is that, if fx. a job should be set to "ready" after failing, I want to be able to set the job to "ready" from the page loaded from the temp table.
However, since the ID-GUIDs are no more unique than appearing as ID's in the various companies, I have had to CLEAR the GUIDs and create new ones for the temp table in order to get all the data with unique IDs. The problem about that is of course that I have now lost the original GUID and therefore the reference for the entry in the original table, and thus cannot perform any actions on the original table.
Is the a neat solution to this that I'm missing?
Thanks
I have this code to read data into the temp table:
IF Company.FINDSET THEN REPEAT
IF jobqueueEntry.CHANGECOMPANY(Company.Name) THEN BEGIN
IF jobqueueEntry.FINDSET THEN
REPEAT
Rec := jobqueueEntry;
CLEAR(Rec.ID);
Rec.ID := CREATEGUID;
Rec.Text1 := Company.Name;
Rec.INSERT;
UNTIL jobqueueEntry.NEXT = 0;
END;
UNTIL Company.NEXT = 0;
However, since the ID-GUIDs are no more unique than appearing as ID's in the various companies, I have had to CLEAR the GUIDs and create new ones for the temp table in order to get all the data with unique IDs. The problem about that is of course that I have now lost the original GUID and therefore the reference for the entry in the original table, and thus cannot perform any actions on the original table.
Is the a neat solution to this that I'm missing?
Thanks
I have this code to read data into the temp table:
IF Company.FINDSET THEN REPEAT
IF jobqueueEntry.CHANGECOMPANY(Company.Name) THEN BEGIN
IF jobqueueEntry.FINDSET THEN
REPEAT
Rec := jobqueueEntry;
CLEAR(Rec.ID);
Rec.ID := CREATEGUID;
Rec.Text1 := Company.Name;
Rec.INSERT;
UNTIL jobqueueEntry.NEXT = 0;
END;
UNTIL Company.NEXT = 0;
0
Best Answers
-
One of possible solutions, witout a need of modifying any table:
This is your temp buffer:IF Company.FINDSET THEN REPEAT jobqueueEntry.CHANGECOMPANY(Company.Name); IF jobqueueEntry.FINDSET THEN REPEAT TempTable823.ID +=1; TempTable823.Name := Company.Name; TempTable823.Value := FORMAT(jobqueueEntry.ID); TempTable823.INSERT; UNTIL jobqueueEntry.NEXT = 0; UNTIL Company.NEXT = 0;
The page displaying the Job Queue entries across companies is based on table 823, and has a global JobQueueEntry record. Fields from global JobQueueEntry var can be displayed on the page.
You run this page by calling PAGE.RUN(yourpageID, TempTable823)
Then in on OnAferGetRecord (or in OnAferGetCurrentRecord if the page is Card) you can do:JobQueueEntry.CHANGECOMPANY(Name); EVALUATE(JobQueueEntry.ID, Value); JobQueueEntry.FIND;
Then your Actions can use current value of global JobQueueEntry rec.
Since the table used to buffer JobQueueEntry PKs per company is a simple one it will not allow you to filter for any specific values from any field from Job Queue Entry table.
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-035 -
I would normally build a function, the first part of it would be the code populating temp table based buffer, and righ aftter that a call to PAGE.RUN (or PAGE.RUNMODAL)
PROCEDURE CheckJobQueues() BEGIN IF Company.FINDSET THEN REPEAT //.. UNTIL Company.NEXT = 0; PAGE.RUNMODAL(YourPageID, TempTable823); END
I woud then call the function from an Action. If the function was meant to be used form more than one place I would put it in a separate codeunit. If you have a spare codeunit to be used just for that you can stick all the code in OnRun() trigger, and then you could link it to the menu, etc.Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-035
Answers
-
Hi, I find it very strange if you are getting the same guid for more than one record, it should not be possible. Is it possible you need to clean some stuff out of your temp table when running the code? If you really have records with the same guid could you store the original guid in another field?0
-
@Juhl I am not allowed to make changes to our tables as things are at the moment, unfortunately.
@wait I guess I could save the original guid in some other fields. A guess key:value would be optimal but that doesn't seem to be an option with c/al. Id rather not hardcode 15 variables. Do you have an idea for this?0 -
One of possible solutions, witout a need of modifying any table:
This is your temp buffer:IF Company.FINDSET THEN REPEAT jobqueueEntry.CHANGECOMPANY(Company.Name); IF jobqueueEntry.FINDSET THEN REPEAT TempTable823.ID +=1; TempTable823.Name := Company.Name; TempTable823.Value := FORMAT(jobqueueEntry.ID); TempTable823.INSERT; UNTIL jobqueueEntry.NEXT = 0; UNTIL Company.NEXT = 0;
The page displaying the Job Queue entries across companies is based on table 823, and has a global JobQueueEntry record. Fields from global JobQueueEntry var can be displayed on the page.
You run this page by calling PAGE.RUN(yourpageID, TempTable823)
Then in on OnAferGetRecord (or in OnAferGetCurrentRecord if the page is Card) you can do:JobQueueEntry.CHANGECOMPANY(Name); EVALUATE(JobQueueEntry.ID, Value); JobQueueEntry.FIND;
Then your Actions can use current value of global JobQueueEntry rec.
Since the table used to buffer JobQueueEntry PKs per company is a simple one it will not allow you to filter for any specific values from any field from Job Queue Entry table.
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-035 -
0
-
I would normally build a function, the first part of it would be the code populating temp table based buffer, and righ aftter that a call to PAGE.RUN (or PAGE.RUNMODAL)
PROCEDURE CheckJobQueues() BEGIN IF Company.FINDSET THEN REPEAT //.. UNTIL Company.NEXT = 0; PAGE.RUNMODAL(YourPageID, TempTable823); END
I woud then call the function from an Action. If the function was meant to be used form more than one place I would put it in a separate codeunit. If you have a spare codeunit to be used just for that you can stick all the code in OnRun() trigger, and then you could link it to the menu, etc.Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-035 -
[Topic moved from 'General Chat' forum to 'NAV Three Tier' forum]
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!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