Jump to content

How do I get a customer ID into a new order?

Robert T

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

Recommended Posts


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


Link to comment
Share on other sites

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

This topic is 5735 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.