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 do I get a customer ID into a new order?

Featured Replies

Hello,

I looked around and could not find the answer to this specific question.

My problem is a simple one, I believe.

I have a table named Customers and a Customer Detail layout. I also have an Orders table and a layout named Orders. I have a relationship setup between primary key Customer ID in Customers table and secondary key Customer ID in Orders table.

In many invoicing systems you enter customers and then create orders by selecting a customer from a list of related records. I want that ability but I want something else to happen before you get to that point.

I want to have a button in my Customer Detail layout named Add New Order so that when I enter a new customer I can just click the button and begin creating order info for that Customer.

I can't seem to figure out how to do this. Can someone direct me to an answer?

Thank you

Robert

Sorry, just realized after posting that you have FM7. Substitute the local variable with a global field, ie, where you see $ replace with your global field.

There are several ways of doing this either by using scrip variables or good ol "global field" and better still is to create the reords using a portal where you enable "Allow creation of related records using this relationship", etc.

If you want to use script variables, it could be something like this:

Set Variable [$pk_Customer_ID; Main::Customer_ID]

Go to Layout [Orders]

New Record [ ]

Set Field [fk_Customer_ID; $pk_Customer_ID]

Set Field [OrderDate;Get(CurrentDate)]

Go to Field [fk_Item_ID]

Pause/Resume Script [ ]

Go to Field [Quantity]

Pause/resume script [ ]

.

.

.

Commit Record/Request

Go to Layout [original layout]

This is a basic way of getting you going. What happens here is when a user clicks on the button tied to thi script, it sets the the variable to the primary key of the current record, goes to the orders layout, creates a new record in the orders table, sets the foreign key to the primary key of the original table Customers. You can have a lookup that will lookup any info in the customer table. Goes to the foreign item ID and this could be a dropdown list of your items. Once selected, hit enter and it goes to the next field.

When done, takes you back to your original customer layout.

Edited by Guest
Wrong FM version

  • Author

No, I do have FMP 8. It is in the post, just not in the profile.

which reminds me, I need to update my profile too from FM7 to FM8.

Create an account or sign in to comment

Important Information

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

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.