Jump to content
Server Maintenance This Week. ×

creating a new record in new layout


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

Recommended Posts

Hi

 

I have 1 layout (customers) with customer details in it,

 

but i want to place a button on (customers) layout that would take me to layout 2 (invoices)

 

and insert the same customer id as well as create a new invoice id record

 

i already have 

 

Customers table field name  __pkCutomersID

 

Invoices table field name __pkInvoiceID  & _fkCutomersID related to __pkCutomersID

 

i have tried many ways but with no luck

 

Thank you all in advance

Link to comment
Share on other sites

If the relationship from customers to invoices has create turned on in Invoices a script that sets any field in the Invoices table from the context of Customers will create a new Invoice record if none are present.

 

So if in your script you setfield Invoice::_fkCustomerID = Customers::__pkCustomersID a new invoice will be created IF their are not already matching records.

 

if their ARE matching records then you wil be EDITING the (first by relationship sort order i think) matching Invoice for the Customer

Link to comment
Share on other sites

Assuming that after creating a new invoice for the customer, you want to start editing it in on the Invoices layout* – enter the date, add line items etc. – the basic approach is …

(on the Customers layout)
Set Variable [ $customerID ; Customers::__pkCustomerID ]
Go to Layout [ Invoices ]
New Record/Request
Set Field [ Invoices::_fkCustomerID ; $customerID ]
# end script; start editing your new invoice 

Add the usual sanity checks to the beginning of the script; e.g. if the found set is empty, exit the script and do nothing.

 

*as opposed to scenarios where you can edit/configure the related records conveniently in a portal on the parent layout; so you would create a new record, then remain on / return to the parent layout

Link to comment
Share on other sites

1.  On the Scripts menu, go to Manage Scripts.

2.  Bottom left hand corner, click new.

3.  Use the script Eos provided, Changing field names and layout names to match your DB.

4.  Save Script.

 

5.  Go to the layout you want to invoke the script, enter Layout mode.

6.  From the toolbar, click the Button Tool.

7.  Draw the button on the layout, the button menu pops up.

8.  Click Perform Script, then to the right click Specify.

9.  Pick the Script you just wrote, Click ok (close the window), click ok, close the window.

10.  Now you're back on the layout with a blinking cursor, type what you want on the button (you can add a tooltip from the inspector if you want.

11. Save and go back to Browse Mode.

Link to comment
Share on other sites

thanks for your help but im missing a step i think

 

1.  On the Scripts menu, go to Manage Scripts.   All OK

2.  Bottom left hand corner, click new.  All OK

3.  Use the script Eos provided, Changing field names and layout names to match your DB.  Stuck

4.  Save Script.

 

im stuck at step 3 when i click new i get a pop up that wont let me paste on what Eos provided i have to choose from the menu on the left 

Control

Perform script  is what i select then im asked to specify script  which i do then when i paste Eos script i get errors like the specified table cannot be found which is Set Variable highlighted

Link to comment
Share on other sites

You really cant copy/paste in this situations. You have to click the script steps from the left, and put in the proper parameters.

For example when you double click 'Set Variable' on the left, Set Variable pops up on the right. Then in the bottom right you see buttons you click where you enter $customerID, etc. You don't type in all the punctuation, FM puts them in for you.

I strongly recommend you grab a copy of The Missing Manual.... or the FileMaker Training Series and follow along the sample files. I jumped into my first database, realized it was very confusing. Then I went through both of those books, as well as other reference materials. It helped a lot. You want to learn as much as you can before you get too far down a possible wrong path then realize you have to start over.

Link to comment
Share on other sites

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