boyblunder Posted September 24, 2007 Posted September 24, 2007 I have a unique CustomerID in my Customer file for every customer. What I want to be able to do is have a script button from my customer file that will make a new record in the Invoice file for that customer so the CustomerID and CustomerName will show on the invoice and make that invoice unique for that Customer. One other thing that is important is if this button is ever clicked again for a current CustomerID that it “does not” go to the Invoice file and make another Invoice number. If the CustomerID is already in the system, we would like the button to return them to the Home page. I would sure appreciate your help, Carl
Fitch Posted September 24, 2007 Posted September 24, 2007 1. Make a layout in your Customer file that's based on your Invoice. That will make the scripting simpler; otherwise we'd need a script in the Invoice file. 2. Make your script: If( not IsEmpty( Invoice: CustomerID ) Go to layout( Home ) Exit script End If # Set variable( $id ; CustomerID ) Go to layout( Invoice ) New record Set field( CustomerID ; $id ) Go to layout( original layout ) # // do you want to go to the new invoice? Go to related record( Invoice ; use external file's layouts ) Select window( Invoices )
boyblunder Posted September 24, 2007 Author Posted September 24, 2007 Hi Fitch and thanks for the reply, RE: 1. Make a layout in your Customer file that's based on your Invoice. That will make the scripting simpler; otherwise we'd need a script in the Invoice file. I'm sorry but I don't even know what that means about putting a customer file based on your invoice. I thought I could actually go to the invoice file layout and have the customer id and name show there in a new record. I thought I saw this in a database before, but maybe it wasn't Filemaker. And how would I be able to scroll invoices and use a line items portal if i'm in the customer file? I guess I have to go back to the drawing board because I'm really confused now. But I thank you for answering me. Carl
Fitch Posted September 24, 2007 Posted September 24, 2007 Carl, do you know how to make a new layout? If so, make a new layout in your Customer file. In the New Layout dialog it says "Show records from:" and that's where I'm saying to specify your Invoices file. ***This is only for the purposes of running the script above. Don't panic.*** An alternate way to do it is to make a script in the Invoice file like this: New record Set field( CustomerID ; Get ( ScriptParameter )) Select window( Current Window ) Let's call the script "Create New Invoice." Now back in the Customer file, your script would look like this: If( not IsEmpty( Invoice: CustomerID ) Go to layout( Home ) Else # Perform script( "Create New Invoice" from file: "Invoice" ; Parameter: CustomerID" ) End If Let me know if you need more help. No need to throw up your hands after the first response.
boyblunder Posted September 25, 2007 Author Posted September 25, 2007 Hi Fitch, I set up the two scripts and it’s not working. It’s because I did a poor job of explaining. Please let me try again. The customer has already been assigned a new record with a unique CustomerID and has filled out their customer information. I want this new button to go to the Invoice TO layout and create a new Invoice for this customer. That is really the main thing I need is to be able click the button in the customer file and get that customers CustomerID and CustomerName onto an invoice in the Invoice TO. I guess like any other invoicing system. What I was saying before and saying it poorly is that, If this specific customer, call them CustomerID 1234, has already been assigned an invoice in the Invoice TO, DO NOT make them a new Invoice, just go to that customers invoice in the invoice file that they were already assigned. I had said in the earlier post to go to the Home page but that was not correct. BTW each customer is only assigned one invoice number. They will never be assigned another. Once they have been assigned an invoice number the only changes ever made to the invoice is through the Line Items portal on the Invoice. I know that may seem strange, but that’s how things work here. I’m very sorry for my first “Very Poor” information. Carl
Fitch Posted September 27, 2007 Posted September 27, 2007 ... it’s not working That's pretty vague. What's not working? Look at my first reply. That's essentially the script you want, except where it says: Go to layout( Home ) Change it to: Go to related record( Related::Invoice ) Of course, you'll need to adjust it to match your field and TO names.
boyblunder Posted September 27, 2007 Author Posted September 27, 2007 Hi Fitch, Maybe the best thing for me to do is show you the two scripts. This button is on my customer layout. NEW script Set Variable ($id;CustomerID) Perform Script [“Create New Invoice”] CREATE NEW INVOICE script Go to Layout [“Invoice” (Invoices)] New Record/Request Set Field [invoices::CustomerID; Get (ScriptParameter)] Select Window [Current Window] With these scripts I go to the invoice layout and a new record is created. But the Customer ID is not created with it. I still want what I said from my first post. [color:blue]"One other thing that is important is if this button is ever clicked again for a current CustomerID that it “does not” go to the Invoice file and make another Invoice number. If the CustomerID is already in the system, we would like the button to return them to the Home page." But was unable to get that working either. What have I done wrong? Carl
bruceR Posted September 30, 2007 Posted September 30, 2007 "What have I done wrong?" You have left things out of your explanation. Presumbly you don't really mean what you say. You want one unique record in the Customer table for a customer; and you would allow one customer to have 1 or more than one records in the invoice table. Or do you really mean that you only want to allow a customer to have one invoice and never buy from you again?
boyblunder Posted October 1, 2007 Author Posted October 1, 2007 Hi Bruce, Or do you really mean that you only want to allow a customer to have one invoice and never buy from you again? I'm sorry I don't mean that at all. We will have a new invoice for every customer new order. What I really meant is I do not want a new Invoices assigned if a customer clicks this specific button again. But I've handled that by setting up another layout without the button. So what I’m after is just the ability to click on a button in the CustomerTO customer layout, capture the CustomerID, go to the InvoiceTO Invoice layout and have a new record created with this CustomerID. Can you help me with this? Carl
Fitch Posted October 1, 2007 Posted October 1, 2007 It looks like you didn't pass the script parameter into the "Create New Invoice" script. It should look like this: Set Variable ($id;CustomerID) Perform Script [“Create New Invoice” ; Parameter: $id ] One other thing that is important is if this button is ever clicked again for a current CustomerID that it “does not” go to the Invoice file and make another Invoice number. If the CustomerID is already in the system, we would like the button to return them to the Home page. This should be in the FIRST part of your script: If( not IsEmpty( Invoices: CustomerID ) Go to related record( Invoices:: CustomerID ) Exit script End If
boyblunder Posted October 1, 2007 Author Posted October 1, 2007 Hi Fitch, What in the world is wrong here. Why can't I do what would seem to be the most simple thing in the world? You said: Perform Script [“Create New Invoice” ; Parameter: $id ] I get the Perform Script part, but where do I put the "; Parameter: $id ]" part of it? It looks to me that the scripts I posted under post 267828 are the same you just gave me other than the "; Parameter: $id ]" and as I said I have no idea where that goes. I know you guys want to get rid of me and I don't blame you. I just really need to be able to do this and all I keep doing is going in circles. Carl
Fitch Posted October 3, 2007 Posted October 3, 2007 When you are in the dialog where you select which script you want to run, there is a space at the bottom where you enter the parameter.
boyblunder Posted October 3, 2007 Author Posted October 3, 2007 Hi Guys, I never thought of myself as a quitter but maybe I am. I'm asking you guys to spend all this time and I'm getting nowhere. I'm just going to stay with my old Copy & Paste. I'm told time and time again that's not the way to do it any more. But I follow what you guys say and get nowhere. Obviously not your fault, it's mine. Why I can't perform what looks to be the simplest thing in the world I don’t know. All I know is I can't get it to work. The script I have now that will copy my CustomerID from my customer layout and go over to my invoice layout, make a new record and paste it into the CustomerID works without a hitch. That works so I guess that’s what I need to do. All I know is I've wasted enough of everyone's time and it gets a little embarrassing to keep coming back with the same song and dance. Thank you all for your help, but look at this. I have 14 posts and 7 of them are here on the exact same thing. I give up! Carl
Fitch Posted October 4, 2007 Posted October 4, 2007 Carl, if you're willing to take one last stab at it, take a look at the example file I've attached. If that doesn't help, you can also send me a clone of you file and I'll set it up for you. script_example.zip
boyblunder Posted October 4, 2007 Author Posted October 4, 2007 Hi Fitch, aka “The Poet of Portland”, That did it and I thank you so much for the file. I saw what you did and all of a sodden it clicked. I was reading something on the forum the other day, I think it was on the Cafe, where somebody said they had a quote by their computer that said “To error is human but to really screw up requires a computer”! How true is that? Sometimes you just feel so stupid. Here you are laying the whole thing out for me and I can’t even follow instructions. I sure feel better now and thanks for not just letting me quit Fitch. It was also very considerate to send a file. I’ve heard nothing but good things about this forum and I see why. Thanks for keeping me in the game. Carl
boyblunder Posted October 6, 2007 Author Posted October 6, 2007 Hi Fitch, I didn't find out until yesterday afternoon that along with the CustomerID we also need the CustomerName. Can you show me how to add this to the script so it shows on the Invoice as well? Thanks Fitch, Carl
Recommended Posts
This topic is 6259 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