Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5869 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted

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

Posted

Close Window

Refresh Window

Refresh *which* window... it may have just been closed.

Posted

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. :wink2:

LaRetta

Posted

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

Posted (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! :wink2:

UPDATE: Last condition? There doesn't appear to be one. Either way the window closes.

Edited by Guest
Added update
Posted

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.

Posted

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. :tongue2:

Thank you both!

  • Newbies
Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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