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.

Checking a Unique Key against Existing Ones in Many to Many relationship

Featured Replies

  • Newbies

For the life of me I don't understand why it does not work

I am redesigning my invoice database that originally was done in FM 6, but now making it in 8.5

Before, I had three files: Invoices, Fees, Invoice Items.

In order to avoid adding duplicated invoice items to Invoice, I had a calculation as a unique ct_invoiceID_feeID_key ( invoice_id & "-" fees_id) set up in Invoice Line Items file.

Upon adding a new invoice items, the script was setting up a global field in Invoice Item file with that unique concatenated key of a new invoice items I am about to add, and then invoking a script in Invoice Items files to check this global key fee against keys of existing invoice items ( Using script

If ( Count( ct_inv_fee_key ) > 0)

Exit Script

See the attached screenshots.

Now, I am using variables, and yet i cannot get this to work. No matter if I add another fee or an already existing on the invoice one, Count calculation doesn't work, it always finds an existing key. I tried using

If ( $invoice_fee_key = Inv_line_items::ct_inv_fee_key )

Still no go. I realize it doesn't search of matching keys.

I figured a work around using Loops, and searching for a key, but it is too cumbersome. I am surely missing something.

fm6_invoice_line_item_script.jpg

fm8_invoice_line_item_script.jpg

Why are you going to inv_line_items and doing a count on ct_inv_fee_key? This only checks the current record that you are on in inv_line_items.

  • Author
  • Newbies

because I am not sure what I am doing? :'(

In old file format I had a script brought up from Invoice Line Items file to execute that Count calcluation.

Besides, it does not work even if I take "Go to Invoice Line Items table" out. I am confused.

  • Author
  • Newbies

here is a simplified copy. thank you!

I need to check if such a unique key ( invoiceID & feeID) already exists in this invoice. I can create a field validation in invoice items, but how I can gracefully do it with a script? And why it worked before in FM6?

inv_fee_invitems.fp7.zip

  • Author
  • Newbies

Thank you.

Sorry, I am late with replying: was internetless for a few days.

It is very interesting solution. I will try this and also try out recreating the older solution using globals rather variables.

Thank you again

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.