October 30, 200817 yr Newbies 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
October 30, 200817 yr Close Window Refresh Window Refresh *which* window... it may have just been closed.
October 30, 200817 yr 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
October 30, 200817 yr 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
October 30, 200817 yr 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, 200817 yr by Guest Added update
October 30, 200817 yr 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.
October 30, 200817 yr 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!
October 30, 200817 yr Author Newbies 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.
October 30, 200817 yr No we were just suggesting what you should put inside your two if statements! --sd
Create an account or sign in to comment