Jump to content
Sign in to follow this  
wootten

copy a group of records

Recommended Posts

i have a relationship between customers and customer products.

for customer abc i want to copy all their products to customer bcd.

any help would be appreciated.

Share this post


Link to post
Share on other sites

Not sure if you've caught up with my previous post on this topic, but in case you haven't, here's the gist...

There are perhaps several ways to approach your problem, however I recommend an approach based on three global fields and a script.

The global fields should sit within your products file, and should comprise two global text fields named 'gCopyFromID' and 'gCopyToID', plus a global number field called 'gScript_temp.num'.

To begin the process it will be nessesary to place the customerID (ie the contents of the field which is the key field for the link between the customers and products files) for the customer whose products you want to copy and the customer you want to copy them to into the gCopyFromID and gCopyToID fields respectively.

How you'd like to go about doing this depends on what suits the work-flow best, but one way would be to place them on a layout within the customers file (you can access them via the relationship to the products file) so that they can be filled either by drag-and drop from the customerID fields in the records of that file. Alternatively the user could manually enter the copy from and to IDs directly into the global fields.

For validation purposes, create a value list called 'ClientID_list' in the products file which uses values from the customerID field (ie the key field for your relationship to the products file).

Once both global fields have values in them you need to call a script in the related file which finds the 'from' records, copies them and re-assigns the copies to the 'to' customer. The script should look something like this:

[color:"green"]Allow User Abort [Off]

If ["IsEmpty(gCopyFromID) or IsEmpty(gCopyToID)"]

Show message ["You must specify both a source and destination client record. Please check and try again."]

Exit Script

EndIf

If ["gCopyFromID = gCopyToID)"]

Show message ["The destination client ID must not be the same as the source Client ID. Please check and try again."]

Exit Script

EndIf

If ["PatternCount(ValueListItems("products.fp5", ClientID_list"), gCopyFromID) < 1"]

Show message ["The source client ID you have entered is not valid. Please check and try again."]

Exit Script

EndIf

If ["PatternCount(ValueListItems("products.fp5", ClientID_list"), gCopyToID) < 1"]

Show message ["The destination client ID you have entered is not valid. Please check and try again."]

Exit Script

EndIf

Set Field ["gScript_temp.num", ""]

Enter Find Mode [ ]

Set Field ["ClientID", "gCopyFromID"]

Perform Find [ ]

Loop

Set Field ["gScript_temp.num", "gScript_temp.num + 1"]

Go to Record/Request/Page [gScript_temp.num]

Duplicate Record/Request

Set Field ["clientID", "gCopyToID"]

Omit Record

Exit Loop If ["gScript_temp.num = Status(CurrentFoundCount)"]

End Loop

Set Field ["gScript_temp.num", ""]

Set Field ["gCopyFromID", ""]

Set Field ["gCopyToID", ""]

Show All Records

Perform Script ["Sub-scripts", External: "customers.fp5" - {script which returns the user to customer file}]

Toggle Window [Hide]


Once the required fields and the script are in place, you'll want to make a copy of the files and run some thorough tests to make sure all is working as it should before 'going live' with the new system.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.