Jump to content
Sign in to follow this  
michaeldaly

script to create and populate new portal row

Recommended Posts

I'm really sorry about this... It's probably the most basic question ever asked but I'm really struggling to achieve the following:

I have an invoice table and the layout contains a portal in which I create records in my line table. I'd be grateful if someone could tell me what script to use in order automatically to complete the next portal row (so create another line) if a specified field in the current row contains a specified word.

To explain; we sell shoes. The portal includes the fields "make" "style" "dye_or_taken" and "price". The "dye_or_taken" field is a drop-down list including "dye". If "dye" is selected in the current line, I want to automatically generate the next line and insert "dyeing service" in the "style" field and "20" in the price field.

Any help most gratefully received.

Share this post


Link to post
Share on other sites

This isn't typical. Usually, you'd have a parts or inventory table. Then, when you enter the part or inventory number, the fields for Price, Make, Style, etc., would lookup from the inventory table into the line items table. You wouldn't skip lines in the line items table.

Share this post


Link to post
Share on other sites

Many thanks for your response. I do have an inventory table (I call it "stock") in which one of the "styles" is "dyeing service". I want to show the shoes as an item sold on one line, then the dyeing service as a separate item (or "style") on the next line. Naturally, this would be easily and quickly carried out manually but I thought it would be neat if it could be entered automatically with a script.

If you have any further thoughts, they'd be welcome.

Share this post


Link to post
Share on other sites

Well, you're really selling two things, the shoes (line item#1) and the dyeing service (line item#2).

You could script adding two line items and assign the script to a button. However, that would enter a specific stock# for each line item.

Share this post


Link to post
Share on other sites

Aha - that would be perfect. I'd really appreciate it if you could tell me the steps of a script that would do that, as I'm really struggling to get anywhere with it.

Thanks again

Share this post


Link to post
Share on other sites

Here's an Invoice Demo. It shows not only how to add two line items to an invoice via a button, but some basic "how to" build an invoice. I used the Anchor-Buoy method in the Relationship Graph (my preferred method), zz_fields that I always put in every table, and my standard field naming conventions.

Hope this helps get you started.

InvoiceDemo.fp7.zip

Share this post


Link to post
Share on other sites

Well, that's very kind of you to take the trouble to do that - it's a great help.

Best regards and thanks again,

Michael

Share this post


Link to post
Share on other sites

Since you have FileMaker 10 you can use a script trigger for this and skip the extra click.

Share this post


Link to post
Share on other sites

Yes, that's what I thought but, being a complete beginner, I couldn't put together a script that did the job! I tried to write it so that, if "dye" was selected on one line, it generated the next line with "dyeing service" in the "style" field.

I had a script trigger on modification of the field "dye_or_taken" and after hours of tinkering with it my best effort at a script was:

If [line::taken_dye = "Dye]

Go to Portal Row [select; Next]

Set Field [line::style["Dye Service"]]

End If

If you can point out my error(s) I'd be only too pleased. If not, I'll play around with the demo kindly donated above.

Thank you

Share this post


Link to post
Share on other sites

The set field line looks weird. I think you have have put "Dye Service" where you specify a field's Repetition.

Go back into the script and click the Set Field step. Notice that there are two Specify buttons.

Click the first button, select the field, and set the Repetition to 1 (normally you just leave that alone). Click OK.

Click the lower button, and type your text there (in quotes). Click OK.

Your script line should now look like this:

Set Field [line::style; "Dye Service"]

Share this post


Link to post
Share on other sites

Yes! Fantastic. Thank you so much. I know it was such a simple thing but I really searched and couldn't find it explained in basic steps anywhere. You saved me!

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

Important Information

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