Jump to content
Sign in to follow this  
cameroncaley

Getting Script to run automatically

Recommended Posts

So, I've been tasked with getting our FileMaker 10 working more the way we want it for 2015. I've already managed to get the layout and calculation issues fixed and working. Now I'm working on some scripting which is an area I've alwasy struggled with. Here is what I need to do. When we write up orders, some customers are tax exempt. I have created a field where I can input an "X" to label as Exempt, but I need to be able to remove the tax from the calculation for just that particular order. Here is a screen shot of the area on the layout I am talking about. Here is the script as I have it set up:

 

If [Workorder::Tax Exempt = "X"]

    Insert Text [select; Workorder::Tax; "Exempt']

End If

 

My question is two part, can the script be set to run automatically upon putting an "X" in the Tax Exempt Box? And can it be set so that if I add more items to the order and it recalculates, that is doesn't put the tax back in?

 

This is a common mistake in our business of someone marking an order as Exempt, but adding more items to it and forgetting to take the tax back off.

post-112652-0-19966500-1419972737_thumb.

Share this post


Link to post
Share on other sites

Why does this need to be scripted? Why not simply calculate the tax (or not), based on the Exempt field's contents (which ideally would be either 1 or empty)?

Share this post


Link to post
Share on other sites

Ok, Maybe I overestimated my abilities when I said "Intermediate" skill level, because I can't figure out how to put that into the calculation. Right now the "Tax" field is set to calculate "Subtotal * .07" What do I need to add in there so that it will not calculate the tax if the "Tax Exempt" field is marked with an "X"?

Share this post


Link to post
Share on other sites

 Right now the "Tax" field is set to calculate "Subtotal * .07" What do I need to add in there so that it will not calculate the tax if the "Tax Exempt" field is marked with an "X"?

 

Try =

Case ( IsEmpty ( Tax Exempt ) ; Subtotal * .07 )

Or, if you accept my suggestion to make Tax Exempt a Number field, using a value of 1 for True:

Case ( not Tax Exempt ; Subtotal * .07 )

Even better would be to use =

Case ( not Tax Exempt ; Subtotal * TaxRate )

and auto-enter the current tax rate into the TaxRate field. Without this, any change in tax rate will modify your existing records, which could be disastrous.

Share this post


Link to post
Share on other sites

Thank you. That worked perfectly. I don't know why I didn't think about using the case function in the calculation. Too close to the problem, I guess.

Share this post


Link to post
Share on other sites

Although your question has definitely been answered correctly, if you do need in the future to run scripts triggered on field changes/saves, look at the script triggers -- FM is quite powerful in this respect.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

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