Newbies Toby Wimberley Posted October 30, 2008 Newbies Posted October 30, 2008 Hi, I wrote this little script to delete accidently created records on exit. [color:green]If [ ServiceHistory::Serial Number = "()" and ServiceHistory::ServiceDate = "()" ] Delete Record/Request Close Window [ Current Window ] Else If [ ServiceHistory::Serial Number ≠ "()" and ServiceHistory::ServiceDate ≠ "()" ] Close Window [ Current Window ] End If Refresh Window What is wrong with this script? Thanks for the help Toby
Vaughan Posted October 30, 2008 Posted October 30, 2008 Close Window Refresh Window Refresh *which* window... it may have just been closed.
LaRetta Posted October 30, 2008 Posted October 30, 2008 Hi Toby, welcome to FM Forums! As Vaughan says, which window should be refreshed. And why? But you don't indicate what is wrong with the script; what doesn't it do for you? I assume it doesn't delete the record because of the next sentence ... "()" is an invalid date. Are you looking for blank ServiceDate or Serial Number? That would be "" but it is better to check using IsEmpty(). You also only have two conditions here; either the record should be deleted or it should not so your script could be shortened to: If [ IsEmpty ( ServiceHistory::Serial Number ) and IsEmpty ( ServiceHistory::ServiceDate ) ] Delete Record/Request End If Close Window [ Current Window ] You can also check if date exists using [color:green]not Service Date. Serial Numbers should also be auto-entered by FileMaker but it sounds like a User types this in? Let us know how we can help you further. LaRetta
Søren Dyhr Posted October 30, 2008 Posted October 30, 2008 IsEmpty ( ServiceHistory::Serial Number ) and IsEmpty ( ServiceHistory::ServiceDate ) Or not Count(ServiceHistory::Serial Number;ServiceHistory::ServiceDate) ...the last condition could go like this: Count(ServiceHistory::Serial Number;ServiceHistory::ServiceDate)=2 --sd
LaRetta Posted October 30, 2008 Posted October 30, 2008 (edited) Cool, Soren! I understand the boolean theory that either field would need a number but I hesitated because I've worked at places with serial numbers that are all text and since it wasn't an auto-generated serial, I wasn't sure. Either way, I would have listed it as [color:green]not Serial Number or not Service Date. I like yours better! UPDATE: Last condition? There doesn't appear to be one. Either way the window closes. Edited October 30, 2008 by Guest Added update
comment Posted October 30, 2008 Posted October 30, 2008 Count() works on text fields just fine, so: not Count ( a ; b ) is the same as: IsEmpty ( a ) and IsEmpty ( b ) or: IsEmpty ( a & b ) and a, b could be numbers, text, dates, times or timestamps.
LaRetta Posted October 30, 2008 Posted October 30, 2008 Count() works on text fields just fine. Oh of course it does, doh. I use it to count related all the time - even text. I'm getting far too mentally soft! It must be all the non-FM playing I've been doing lately; I'm not on my edge. Thank you both!
Newbies Toby Wimberley Posted October 30, 2008 Author Newbies Posted October 30, 2008 Sorry, I should have been more clear as to my problem. You are correct that it is not deleting the record. This is really my first database in File Maker and it is probably all wrong. the inventory::serial is auto entered but the ServiceHistory::Serial is in not. It is copied and pasted into the SerialNumber Field in the ServiceHistory table to keep the records related. To see the mess I have created you can download it. Just let me know and I'll pm you the link. I have tried what LaRetta has suggested but couldn't make it work either. I was completely lost on S0ren and Comment's suggestions. I guess they had set a $variable somewhere?? Thanks again for the help.
Søren Dyhr Posted October 30, 2008 Posted October 30, 2008 No we were just suggesting what you should put inside your two if statements! --sd
Recommended Posts
This topic is 5869 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