Jump to content

copy a group of records


This topic is 7915 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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.
Link to comment
Share on other sites

This topic is 7915 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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