Jonah74 Posted October 11, 2013 Posted October 11, 2013 Hi  Can anyone tell me how to replace a particular fields contents with different values for individual records or serial numbers rather than a found set? At the moment I can get it to replace field contents but it does it for the whole found set not just the one individual record I want. For instance, I have a DB that records car journeys which are given individual record numbers (automatic serial numbers) and has a cost in two fields. What I'm trying to do is: if someone cancels a journey I'd like to be able to click a button that says Cancel and a script runs that looks at that individual record ID and inserts £0.00 in two fields and overwrites the cost thats in it. I'm guessing it's going to be a script with an If statement in it but I just can't figure it out. Any help would be greatly appreciated.
Jonah74 Posted October 11, 2013 Author Posted October 11, 2013 Thanks for the reply but could you elaborate please?
LaRetta Posted October 11, 2013 Posted October 11, 2013 An easy option, I believe, would be to set both Journey Cost and Office Fee to auto-enter calculation of: Case ( your test not to clear the field ; Self ) Back at the auto-enter tab, be sure to uncheck 'do not replace existing value if any'. 'statusField' would be whatever name the field is which is set by the cancellation button. It might be something like: statusField <> "Cancelled" or IsEmpty ( CancelledDate ). Back up first and test it, of course.
Jonah74 Posted October 11, 2013 Author Posted October 11, 2013 The Journey Cost and Office fee are currently free text fields set to currency format because as at the moment each journey can have different costs as does the Office fee. If I change these fields how does the auto enter calculation affect this because as I understand it users cannot enter anything into these fields.?
LaRetta Posted October 11, 2013 Posted October 11, 2013 Auto-enter is not a calculation field. It is standard number or text field where it enters a calculated result and then either stops (if checkbox 'do not replace' is checked) or updates any time itself or a field it references is modified. So if you establish the auto-enter as I described on those two number fields and then you have a checkbox which is called Status and you change the record status to 'Cancelled', and be sure to uncheck 'do not replace' then it will leave its value alone in all cases except if 'cancelled' is checked whereas it will clear the dollar amounts. Back up before testing this.
Jonah74 Posted October 12, 2013 Author Posted October 12, 2013 Hi Thanks for the info but I've gone the Set Field route. I created two set fields which worked but as the pop up button gets its data from a value list, namely: Live or Cancelled, using the Set Field on it's own would insert blanks ("") irrespective of whether Live or Cancelled was selected. By inserting the If statement in front and then adding a script trigger (On Object Save) to the popup button it does the job perfectly. Problem solved and thank you for your advice. Test: Cancel Script If [ Journey::Journey Status = "Cancelled" ] Set Field [ Journey::Journey Cost; "" ] Set Field [ Journey::Office Fee; "" ] End If
LaRetta Posted October 12, 2013 Posted October 12, 2013 Just remember that the script will not clear those fields if the Cancellation is set by any other means other than that single layout where the trigger resides such as setting the status to Cancellation from another location, from import etc. so if someone puts that field on table view, they can change it and the dollar amounts will remain. From that perspective, auto-enter is more dependable since it does not rely on remembering to protect in all situations.
Recommended Posts
This topic is 4059 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