March 23, 200916 yr I need help on this script. I have a layout with 3 different portal tables and the script should make a duplicate record and also duplicate the 3 portal tables. The script works fine with one table but it wont Loop/repeat the other 2, whats wrong with the script? Thanks # # # Set Variable [ $OrigWindowName; Value:Get ( WindowName ) ] Go to Related Record [ From table: “oil_quantities”; Using layout: “oil_quantities” (oil_quantities) ] [ Show only related records; New window ] Select Window [ Name: $OrigWindowName ] Duplicate Record/Request Set Variable [ $NewRecipeID; Value:recipes::recipe_id ] Select Window [ Name: "OilDupes" ] # # # Duplicate Oils Go to Record/Request/Page [ Last ] Loop Duplicate Record/Request Set Field [ oil_quantities::recipe_id; $NewRecipeID ] Omit Record Omit Record Exit Loop If [ Get ( FoundCount ) = 0 ] End Loop # Duplicate adds Go to Record/Request/Page [ Last ] Loop Duplicate Record/Request Set Field [ add_quantities::recipe_id; $NewRecipeID ] Omit Record Omit Record Exit Loop If [ Get ( FoundCount ) = 0 ] End Loop # Duplicate EOs Go to Record/Request/Page [ Last ] Loop Duplicate Record/Request Set Field [ eo_quantities::recipe_id; $NewRecipeID ] Omit Record Omit Record Exit Loop If [ Get ( FoundCount ) = 0 ] End Loop Close Window [ Current Window ] Commit Records/Requests [ Skip data entry validation; No dialog ]
March 23, 200916 yr # # # Duplicate Oils Go to Record/Request/Page [ Last ] Loop Duplicate Record/Request Set Field [ oil_quantities::recipe_id; $NewRecipeID ] Omit Record Omit Record Exit Loop If [ Get ( FoundCount ) = 0 ] End Loop [color:red] >>>>>> # Duplicate adds Go to Record/Request/Page [ Last ] Loop Duplicate Record/Request Set Field [ add_quantities::recipe_id; $NewRecipeID ] Omit Record Omit Record Exit Loop If [ Get ( FoundCount ) = 0 ] End Loop After duping the first set of records, you're left with no found records and you start your next loop. Running this with the Script Debugger on should should you this issue.
March 23, 200916 yr tmas, Have you considered a scripted import instead of fussing with loops? GTRR: primary--> childrenPortal1 Spawn a new CHILD window. Import. Close Window Back to original screen GTRR: primary --> childPortal2 etc... Often much faster than looping scripts for the creation of new records. If you need to set some values, loop through the found set after the import. Good luck! *susan*
March 23, 200916 yr Author So should I repeat the whole top script step? Like this? Sorry but I dont understand the way it repeats. Set Variable [ $OrigWindowName; Value:Get ( WindowName ) ] Go to Related Record [ From table: “oil_quantities”; Using layout: “oil_quantities” (oil_quantities) ] [ Show only related records; New window ] Select Window [ Name: $OrigWindowName ] Duplicate Record/Request Set Variable [ $NewRecipeID; Value:recipes::recipe_id ] Select Window [ Name: "OilDupes" ] # Duplicate Oils Go to Record/Request/Page [ Last ] Loop Duplicate Record/Request Set Field [ oil_quantities::recipe_id; $NewRecipeID ] Omit Record Omit Record Exit Loop If [ Get ( FoundCount ) = 0 ] End Loop Set Variable [ $OrigWindowName; Value:Get ( WindowName ) ] Go to Related Record [ From table: “eo_quantities”; Using layout: “eo_quantities” (eo_quantities) ] [ Show only related records; New window ] Select Window [ Name: $OrigWindowName ] Duplicate Record/Request Set Variable [ $NewRecipeID; Value:recipes::recipe_id ] Select Window [ Name: "EoDupes" ] # Duplicate EOs Go to Record/Request/Page [ Last ] Loop Duplicate Record/Request Set Field [ eo_quantities::recipe_id; $NewRecipeID ] Omit Record Omit Record Exit Loop If [ Get ( FoundCount ) = 0 ] End Loop
March 23, 200916 yr Author Something like this? But how does it know to import this record? Go to Related Record [ From table: “oil_materials”; Using layout: “oil_detail” (oil_materials) ] [ Show only related records; New window ] Import Records [ ] [ No dialog ] Close Window [ Current Window ] Go to Layout [ “recipes” (recipes) ]
March 23, 200916 yr You will need a "shadow table".... I will create a demo file for you. Much easier than describing the process. Duplicating this way only makes sense if the routine is going to be used more than once, i.e. a regular part of the workflow. *susan*
March 24, 200916 yr Author Its basically just for the user to duplicate a existing record incl. its portal entries.
March 24, 200916 yr Got a call from a client... sorry to take so long to create the demo file. This is the general jist though. Think about how to preserve the found set before starting the routine, so that you can return the user to a logical point. Hope this helps! *susan* DuplicateWithImport.fp7.zip
Create an account or sign in to comment