tmas73 Posted March 23, 2009 Posted March 23, 2009 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 ]
David Jondreau Posted March 23, 2009 Posted March 23, 2009 # # # 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.
*susan* Posted March 23, 2009 Posted March 23, 2009 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*
tmas73 Posted March 23, 2009 Author Posted March 23, 2009 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
*susan* Posted March 23, 2009 Posted March 23, 2009 Go To Related Record. Sorry, that is my own mental shortcut. *susan*
tmas73 Posted March 23, 2009 Author Posted March 23, 2009 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) ]
*susan* Posted March 23, 2009 Posted March 23, 2009 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*
tmas73 Posted March 24, 2009 Author Posted March 24, 2009 Its basically just for the user to duplicate a existing record incl. its portal entries.
*susan* Posted March 24, 2009 Posted March 24, 2009 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
Recommended Posts
This topic is 5724 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