Here is a challenge fellows. I have not heard nothing from BD support yet.
Hopefully some of you have the solution.
I'm planning to generate recurring billing, so the goal is to clone a quote (containing relational data) in to another folder. I need to convert quotes to sales orders keeping a copy of the quote on default folder.
I have attached a database with an example of the goal to reach. Also the three buttons are the code that I have implemented with no success.
I will appreciate if you and your guys can give me a hand with this challenge. I'm pretty sure that my code is wrong but I can't figure it out.
If I can find time will have a play around with this problem.
In mean time can I suggest you create master keys and child keys in each form.
This will always allow tracking of related records and be useful if need to export to a different database system.
Yes that is true but it is "internal". Having keys gives you an "visable" options if we run in to problems working out a functional script. Not really that hard to do and little storage space used. If you exported forms to say an SQL database you need some reference keys to link tables. I believe what you are attempting is possible ( even with out keys) but need a quite moment and clear head to work it through.
Also what quantity of records do you expect in quotes and products - may influence method used?
Without knowing what your exact intentions are, I don't see the logic behind your current layout.
Bearing that in mind, I feel that you can make this pretty darn easy on yourself with some minor changes. For example, there is no need to have your products listed 3 times. No need for 4 forms when 2 will do, and no need for so many folders.
A Structure that would make more scene to me would be you have your Quotation folder, Products, and your Sales Orders folder.
You create a quotation for a customer and add your products to that quotation. You do not clone or duplicate the products. So the only new record is the quotation.
If this quotation is to progress into an order, then you select the qutation you gave the customer and press a single button.
The script for the button would work like this.
1: You clone the current record.
2: You move back to the original record.
3: You populate a variable with the contents of the relation field.
4: You move back to your new record.
5: You populate the relation field with the contents of the variable.
6: You move the selected record to your Sales Folder.
Something like that would simplify all this by a long way.
Edit... actually, I'll write this for you. Please see example attached.
Go to the Quotes folder, select a quote and press Run.
If the product data is to be identical after cloning "quotes" then James's idea should work (would need to know all the actual fields used in the real application) . This being the case might it even be possible to just have a single "Quote/Sale form with check box(s) that signals a quote now has a sale status. These could be used for filtering, visability rules, reports etc.
Still would like to investigate cloning relational data independenty from original even as an exercise - adds to knowledge base for future applications.