Automatically populating another table

I need some advice. Once a user has input a quote, another person will need to authorise this quote before they can make an order. My approach is to create a new table to hold the approval records. Therefore, I have created a button called “confirm quote” within the quote form. I then need this to automatically populate key fields within my new table “Quote approval”. Can anyone assist me with this? i.e. What approach do I follow to automatically populate another table once a button is clicked? Thanks

David, I’m not sure I would do this with another table. I did something similar for a client by using the purchase order system as a requisition system. The requisitions needed to be “approved” prior to becoming a PO. To further complicate my case, the client needed up to 4 levels of approval for a requisition depending on the dollar value of it. This is a simplied approach of what I might suggest to you. Add a new boolean field “Quote Approved”. Add some code to the “Make Order” function to not allow the quote to be made into an order unless the quote is “approved”. When placing the new field somewhere on the form, make sure that it is not editable. I would add a new function to “approve” the quote. You might also want to add fields to the table to store who did the approval and the date/time it was approved. In my case of needing multiple approval levels, what I did was add some fields to the User table to indicate the level of approval that each user was allowed to make. For instance, some users could only approve $500 requistions and some could approve $2000 requistions. I put in code to make sure that I $500 approver did not give the “final approval” on a $2000 requistion. You might want to consider doing something similar in order to prevent just any user from approving quotes. I also added code in the approval routine that automatically converted the requistion to a purchase order. By the way, in order to create a way to store the requisitions prior to them becoming a PO, I added a document type of “Requistion” to the Purchase Header and Purchase Line tables. There was a lot more to what I did on my mod, but hopefully this has given you a good starting point for your own. Regards, Mark.

Hello David, Why are you using a separate table if the relation between a quote/order and its approval record is one to one? Personally I would add the fields to the Sales Header table, so that the history is always on the Sales Order (And possibly the Sales Shipment and Sales Invoice Header tables, using the same field Nos. as the Sales Header. The TRANSFERFIELDS in the posting routine will do the rest.) You could then put in some security code (Checking a Boolean field in a table that only Superusers could update, say the User Setup table) to see if they may approve it. Anyway, enough about table relations, back to your query: On the OnPush trigger of the button, put the following: (If you are putting in my solution:) (Security check - Here) Approved := TRUE; “Approved By” := USERID; “Approval Date” := TODAY; MODIFY; If you must have a separate table… Where QuoteApproval is a Global/Local Variable… (Security check - Here) QuoteApproval.RESET; QuoteApproval.“Document No.” := “No.”; QuoteApproval.“Approved By” := USERID; QuoteApproval.“Approved Date” := TODAY; QuoteApproval.INSERT; Please ensure that your button is on Form 41 “Sales Quote” and not on the subform, as it will try to insert the Item/Item/Resource etc. No. into the Document No. field. Pardon me for mentioning it, but you have been posting a lot of design/developer questions recently. You are clearly familiar with development, but not with the Navision environment. It might be a good idea if you looked into going to design/developer course run by an NCP or NSC. I think you might find it beneficial. [:)] Some advice you find on these user groups can also be variable in quality!

Sorry Mark - Looks like you beat me to it!

I had my feelings hurt! [;)] I thought that you must not have found my answer to be good enough! Regards, Mark.

Hello All, Thanks for the excellent advice. I have managed to insert records etc. In terms of the design, I will have to keep the separate table because that is what the client insists on. They want a record of people who have gone in and either approved or rejected the quote. It therefore must remain a one to many. My main problem now is to try to write some to code that will either run from the main form or the sub form. This code will need to run a loop through all records in the subform and then insert them into the new table. So far all my attempts have taken place via a button I have placed on the subform and so far i have been unable to get the loop to work. The main problem is potentially the problem that I do not know how to access variables from the Header of the quote i.e. the sales header. This is easy in asp etc. as you create a recordset and run some sql. How do we do this in Navision? i.e. How do we join two tables/forms within code? Any ideas?

Further to my earlier message, my current position is that I am trying to run this loop and I need to obtain the [No.] from the [Sales Header] so that I can ensure that I only populate my new table with records that are on this form i.e. Not from the entire Sales Line table that is currently happening. Within the F5, Symbol Menu, the CurrForm only shows [No.] which is obviously the Resource or Item Number. Document No. is not there as it is not on the subform. How do I retrieve the [No.] from the Main Form/Sales Header and is this the approach you would take? Thanks again

Hello All, I have solved this one by creating a function in my subform and passing the [No.] to it from the Header. Following many attempts and trial and error, I have got the loop working fine now. This can be frustraiting but there is nothing better than the feeling you get, when you finally get it working…and it helps enhance your understanding of how Navision development is structured. But there is alot more work to do with this…so on with the show… Thanks for your help…