laker_42 Posted February 4, 2004 Posted February 4, 2004 I have a workstation & peripheral database. They are related by computername. When we get rid of a workstation, I want to be able to get rid of the relationship between that workstation and any peripherals that were assigned to it. At first I was just deleting the portal row but then realized what I was doing and stopped doing that. I tried writing a script that simply does a clear(related peripheralfile:computername) but that did not work. Any ideas how I can accomplish this? Thanks! John
Jim McKee Posted February 5, 2004 Posted February 5, 2004 John ... Do you want to: A. delete the peripheral records linked to the Workstation record you're deleting? or B. leave the Peripheral records intact, but remove the workstationID that previously linked them to the Workstation record you're deleting? If "A": In the Edit Relationship window for the linking relationship in Workstations, check the "When deleting a record in this file, also delete related records" option. If "B": Create a script to run from the Workstation record to be deleted along the lines of: Show Related Records [workstationID | Peripherals_workstationID, Show only related] then a Perform Script step to call a sub_script in the Peripherals file along the lines of: Go To Layout (a layout with the workstationID field on it) Replace Contents [workstationID, "", No Dialog] (this will clear the contents of the workstationID field in all related Peripheral records) And, finally, a script step in the main script (in Workstations) to delete the current Workstation record: Delete Record [No Dialog] That should do it.
laker_42 Posted February 5, 2004 Author Posted February 5, 2004 Jim, I need to do option "B". I will give it a try and see what happens. Thanks for the help! John
laker_42 Posted February 12, 2004 Author Posted February 12, 2004 Jim, What if I only want to clear out one of the related peripherals to a workstation? Let's say I have an external hard drive and a monitor assigned to a workstation. The external hard drive is moved elsewhere and we want to reflect this in our DB. How would I only clear out the relationship for the external hard drive? When I go to related records, it doesn't necessarily take me to the correct record that I want to clear out. I think this is simple as well but I have a mental block on how to do this. Thanks! John
Jim McKee Posted February 12, 2004 Posted February 12, 2004 Hi, John ... In that case, on a layout in the Workstation file, I'd have a portal showing peripherals linked to the parent workstation records. Put a button in the portal rows to call a script in the Workstations file: SetField (workstationID | Peripherals_workstationID::workstationID, "") The user clicks the button on the desired peripheral line in the portal, and the workstationID in that related Peripheral record is cleared. Or, if you want to actually view and manually edit the related peripheral record: 1. create a script in Peripherals that goes to the layout you want to be on when you run this script. Let's call it: "gL_Entry" (go to the Entry layout) Go To Layout ("Entry") 2. from the button (above), call a script in the Workstations file: Go To Related Record (workstationID | Peripherals_workstationID) Perform Script (External, "Peripherals.fp5", "gL_Entry") The user clicks the button on the desired peripheral line in the portal. The related peripheral record is displayed, and the gL_Entry script in Peripherals lands the user on the desired layout, where they can perform whatever editing is needed. Of course, alternately, you could have the workstationID field from Peripherals displayed directly in the portal, so you could simply clear it manually there, or enter a different workstationID, as in the case of your transferred hard drive.
laker_42 Posted February 13, 2004 Author Posted February 13, 2004 Jim, Thanks for the help. I had tried your first suggestion before but it wouldn't clear out the field. After further investigation, it was going to a layout that didn't have that field on the layout. There is one thing that is not working quite right. If there are two peripherals assigned to a workstation and I want to get rid of the second peripheral which is in portal row 2. When I click on the button which fires this script, it clears out the relationship for portal row 1. Do I need to add an extra step to get it to delete the portal row that the script is being fired for? Thanks again! John
laker_42 Posted February 13, 2004 Author Posted February 13, 2004 Never mind Jim, I figured it out. I did a combo of both of your suggestions. I created a script in the Peripherals file that set field(WorkstationID, "") and open workstations file. Then in my workstations file script I said go to related record(Peripheral) and perform external script in workstation. Maybe this isn't the ideal way to do it but it seems to work great. If there is any danger of doing it this way please let me know. Thanks, John
Recommended Posts
This topic is 7592 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