Jump to content
proless

How to change value in field?

Recommended Posts

If i have field with number.

How i can automatically make that number 1 smaller when i click Duplicate this record button?

So number is now 7 and in next record it is 6.

Share this post


Link to post
Share on other sites

Hi proless and welcome to the FM Forums,

I sent you a Private Message, please read it, and the link to Anatomy of a Good Topic.

Lee

Share this post


Link to post
Share on other sites

The button would perform a script:

Duplicate Record
Set Field[ fieldwithnumber ; fieldwithnumber - 1 ]

  • Like 1

Share this post


Link to post
Share on other sites

Thanks. I tried to figure out where i need to paste your script but can't figure it out.

Share this post


Link to post
Share on other sites

We don't know if you are working with a sorted set nor whether the record being duplicated is the one 'last visited' or immediately prior so I would suggest, to expand on Tom's suggestion, that you use a script parameter.  Create a script named Duplicate record with these steps:

Set Variable [ $value ; yourFieldHoldingTheNumber ]
Duplicate Record
Set Field [ yourFieldReceivingTheNumber ; $value - 1 ]

Replace the 'yourField' portions of the above script with your actual field name (you can double-click it to insert it).  Then attach this script to a button called Duplicate Record.

And welcome to FMForums!  :-)

Edited by LaRetta
  • Like 1

Share this post


Link to post
Share on other sites

I have never done anything this advanced.

Okay i have now managed to find Script Workspace and created script.

Now i can't figure out how to attach script to Duplicate button.

Thanks

Share this post


Link to post
Share on other sites
  1. Select the object which is your button.
  2. Right-click to bring up the field options.
  3. Select Button Setup.
  4. Select Perform Script and find your script in the list and select it.

There are a few cautions with your concept which I'll mention briefly: 

  • I don't know what you are doing but whether it is clearing month-end values, flagging records, or something else, you will want to include error trapping in case a record is locked and thus can't be modified. 
  • You've rated yourself as Beginner so I doubt you are running a standard Developer process such as synchronizing records.  I am concerned that your script suggests that you might be 'over-working' your data.

You have come to the right place for assistance to help you stay on track so your solution works well.  Let us know how it goes! :-)

Share this post


Link to post
Share on other sites

It's just simple database with plain counter type of thing which is 1 smaller in next record.

"Select the object which is your button"

Button is Duplicate button in Status toolbar. So how i select this button?

Thanks again

Share this post


Link to post
Share on other sites

If you have FileMaker Pro Advanced, you can override the toolbar buttons via Custom Menus.

Or you can just make your own button on the layout.

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


×

Important Information

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