Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to clear out a related record?

Featured Replies

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

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.

  • Author

Jim,

I need to do option "B". I will give it a try and see what happens.

Thanks for the help!

John

  • Author

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

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.

  • Author

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

  • Author

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

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.