netcode Posted December 2, 2008 Posted December 2, 2008 Hello everyone, as the topic says, I am looking at creating a new record via a script. Is this possible? I cannot seem to find the functions to do this. Thanks so much!
bcooney Posted December 2, 2008 Posted December 2, 2008 All you need is the New Record script step in a script.
netcode Posted December 2, 2008 Author Posted December 2, 2008 yes yes I left something out I want this new record function INSIDE an If statement. sorry for leaving that out. Is that possible??
netcode Posted December 2, 2008 Author Posted December 2, 2008 (edited) I did try something else though but I am not sure if it will work... If [] New Record function End If When doing this my first thought is it will trigger regardless because it is not inside the [], but maybe it will? Also when doing this I found out I cannot set parameters for the new record function. I want to be able to create a new record in a different table, how can you specify that table? And set fields all in one? Edited December 2, 2008 by Guest
aldipalo Posted December 2, 2008 Posted December 2, 2008 If(Your Criteria) New Record/request EndIf So, for example. If(Date = Get(CurrentDate) New Record/request EndIf
bcooney Posted December 2, 2008 Posted December 2, 2008 You go to the new table first (Go to Layout), then use the New Record command.
LaRetta Posted December 3, 2008 Posted December 3, 2008 Hi Netcode, you are getting all kinds of help here but maybe it will help to pull all the advice into one script. Let's assume you are on a customer layout of a table occurrence called Customers. And you want to create an invoice for this customer in a table called Invoices. Button to run this script should be on Customers layout: Freeze Window Set Variable [ $customerID ; Customers::CustomerID ] Go To Layout [ Invoices ] New Record/Request Set Field [ Invoices::CustomerID ; $customerID ] Commit Record/Request [color:blue]...now you have a valid relationship between the two so, if there are other fields in Invoices which obtain information from Customers, such as PayMethod, you can use one of three methods: 1) set Invoice PayMethod field to be Auto-Enter (by calculation) or Lookup and specify Customers::PayMethod or 2) simply place your Customers::PayMethod field directly on your Invoice or 3) Set Field [ Invoices::PayMethod ; Customers::PayMethod ] ... then continue your script to allow User entry Go to Field [ ...whichever Invoice field you want your User to begin entering data ] LaRetta
netcode Posted December 3, 2008 Author Posted December 3, 2008 (edited) Great help everyone! I am well on the way to creating this button. I do however have a question for LaRetta, will Freeze Window stop the current window from changing to the layout "Invoices" when the function Go To Layout is processed? If not I want to avoid changing layouts because the record creation is for a join table. Maybe i could just go to layout, then at the end of the script go back? hmmmm *me thinks* And what exactly is the commit record function for? I did read the manual regarding that function but it doesn't make a whole lot of sense to me, maybe hearing it different might help. Something about making a new record regardless if the record can be validated? I dunno lol Also now that I get to thinking about it when you set fields underneath a new record function I assume it sets fields for that record correct? example New Record/Request Set Field Set Field . . . Edited December 3, 2008 by Guest
mr_vodka Posted December 3, 2008 Posted December 3, 2008 Although I am not LaRetta, perhaps I can answer your question in her absence. You can go back to the orig layout when you are done setting your fields. A commit record is used to force the open record to commit (you can think of save).
LaRetta Posted December 3, 2008 Posted December 3, 2008 You may not be LaRetta but I'll bet your legs are cuter! Freeze Window[] stops screen redraw. User won't see what you are doing. It will eliminate flash they would notice from changing layouts, setting fields and so forth. It will NOT stop the script from changing windows.
Søren Dyhr Posted December 4, 2008 Posted December 4, 2008 (edited) And what exactly is the commit record function for? I did read the manual regarding that function but it doesn't make a whole lot of sense to me, I would suggest you jump directly to Ilyse Kazar's on "Record Ownership" in this: http://www.filemaker.com/downloads/pdf/techbrief_fm8_migrtn_found.pdf (Which starts at page 74) But if we take a look at the topic as such, will you if developing a solution gradually without paying too much attention to normalization, such as adding a table here and there as demands arises. What some would characterize as suburban sprawl. This is unfortunately a too commonly occurring scenario, due the flat learning curve filemaker have. If you then step back a little to make abstractions will you discover that ever so often are the scripting of the creation of records pretty similar to each other only really differing with the aspects. Here can it really pay off when you eventually need to restructure the solution at hand, that the scripting gets as uniform as possible, and this can actually be accomplished via script-wrappers, so every call gets massive amount of blackbox content which can be trusted to be left out of eyesight. Now for starters do you of course need to know the meat and potatoes of creating a record via a script, but as soon as know that by heart would I strongly suggest you use all the wrappers you can lay your hands on! Since you often can't tell how healthy your needs for script really are, the danger is often attempts to remedy a poorly structured solution. Take a look at this: http://web.mac.com/zueiv/iWeb/FileMaker/Script%20Killing%20Techniques/AFA363C6-2D85-4C6D-82E2-273F3722A69E.html --sd Edited December 4, 2008 by Guest
netcode Posted December 8, 2008 Author Posted December 8, 2008 Thanks for all the replies everyone! I think I got it all figured out and it seems to be working well yay!
Recommended Posts
This topic is 5830 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 accountSign in
Already have an account? Sign in here.
Sign In Now