Plucky Posted October 20, 2009 Posted October 20, 2009 Hi I have multiple portals on a layout and would like to have a script that can copy all the rows from one portal to another. Portal_1 is a Estimate portal. Portal_2 is the one used for costing. I have other portals on the layout which do not need changing. There can be several rows in the Estimate Portal_1 so I need it to copy all rows and add these to Portal_2 any ideas.
efen Posted October 20, 2009 Posted October 20, 2009 There are a couple of files in this post http://fmforums.com/forum/showtopic.php?tid/211044/post/340267/fromactivity/myposts/#340267 that can be adapted to move all portal entries to another portal (they presently only move one row at a time)
Plucky Posted October 21, 2009 Author Posted October 21, 2009 Hi efen I have it copying over individual records but cannot get it to loop all the records in the portal.
Plucky Posted October 22, 2009 Author Posted October 22, 2009 Hi efen I have tried your example and it seems to keep looping on it self. Can you try the attached example to see what i'm trying to do. I understand the copying into variables it's just the looping bit and how it knows when to stop. Example.fp7.zip
efen Posted October 22, 2009 Posted October 22, 2009 It is a never-ending loop in your file because you haven't specified when it is to stop - the Exit Loop If step is missing the "stop" - the number of rows in the portal. You need an extra field (in my example file it is called "total")in your Orders table - an unstored calc field showing the number of related records in the portal you are transferring from (EstimateLine) Define this total field as Count(EstimateLine::EstimateID) Add the "stop" condition to the Exit Loop If as $counter=EstimateLine::total+1
efen Posted October 22, 2009 Posted October 22, 2009 (edited) Uh-oh Just did this in your file, assuming it was set up like mine, but it doesn't work. Your relationships are different and you have allow creation/deletion of related records. I don't have time to look at/change this at the moment... The "stop" should be Exit Loop If $counter= total field +1 This works when there is more than one portal row. You need to add/amend the script to accommodate these. Edited October 22, 2009 by Guest change calc + text
lastpass Posted January 17, 2010 Posted January 17, 2010 (edited) Hi! I have almost the same problem like Plucky had and I try efen advice but that didn't work. I set up the exit loop with 'Max ( EstimateLine::EstimateID )'. It seems working but if I delete a portal row it can be made mistakes? Like if rows empty the loop will never ending... . And if you push copy button again the portal rows will duplicated. Wich is the best solution for these problems? And how can I copy just the marked ones? (chekbox in the 'ordered' field). Thank you in advance! Example_mod1.zip Edited January 17, 2010 by Guest
bruceR Posted January 18, 2010 Posted January 18, 2010 Try this. Uses auto-create relation and Resource table w/global fields. Example_mod1.fp7.zip
RodSierra Posted January 18, 2010 Posted January 18, 2010 Am I missing something here or can this be done much more simply by establishing a found set for the source of an import by using GTRR, then importing that found set in the destination table. Other point if I need to loop thru a portal with a create option set, I test to exit the loop by checking if the key field to the relationship is empty, this will find the last portal row every time. Don't want to derail the current discussion, sorry if I did.
lastpass Posted January 18, 2010 Posted January 18, 2010 Thanks the answers and the file. I thought FM will be easier like it described in the homepage: "Award-winning, [color:red]easy-to-use database software..." I don't understand your method (yet) but thank you very much! I completed script with an 'If' and 'Set field' orders and I created a 'lock field' at 'orders' layout. These make it possible to pressing the button just one time. Next time will exit from script. (attached if anyone needs and sorry for my language mistakes )
bruceR Posted January 19, 2010 Posted January 19, 2010 Am I missing something here or can this be done much more simply by establishing a found set for the source of an import by using GTRR, then importing that found set in the destination table. Other point if I need to loop thru a portal with a create option set, I test to exit the loop by checking if the key field to the relationship is empty, this will find the last portal row every time. Don't want to derail the current discussion, sorry if I did. I never walk portals. And I hardly ever go to any other layout to create records - needless flashing. I consider walking portals a very bad and vulnerable idea. By using the technique illustrated in my example you have a way to select and operate on records for other purposes. By putting the globals in the Resource table the basic data tables remain uncluttered of additional global fields. Yes, the import option would be valid also. The looping set field script allows you to have some control over what happens to each field if that is important.
lastpass Posted January 19, 2010 Posted January 19, 2010 I try to modify the example file to my own imagination but I met with some heavy difficulties and I can't figured out how can I make this: I want to use second portal (polymer) to an other layout. And I want to polymer portal contained the estimate record ID and the new Polymer record ID. I want to create an order database based on outgoing quotation. But some orders come directly from my partners without outgoing quotation. So I need to copy portal rows from quotations to orders and make orders independently. Can you help me?
lastpass Posted February 1, 2010 Posted February 1, 2010 I tried many ways to copy portal rows into an other wich is in a different layer but I can not figured out how will it work. I attached a sample (based on previus files, FM10) wich has a problem: the portal rows displayed in an other record. If anyone could help me I will appreciate. Copy_portal_row_EN2.zip
merkaba22 Posted March 2, 2010 Posted March 2, 2010 The example is not downloading -- is there a way to repost?
merkaba22 Posted March 2, 2010 Posted March 2, 2010 (edited) deleted by user Package1toEstimator.pdf Edited March 2, 2010 by Guest
merkaba22 Posted March 2, 2010 Posted March 2, 2010 (edited) moved to another area Edited March 2, 2010 by Guest
Recommended Posts
This topic is 5449 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now