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

help with simple calculation


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

Recommended Posts

Hi All

Looking for some help with what should be a simple calculation to validate a set of fields via a script...

If [(Clips::Used = "ELearning") and (IsEmpty ( Clips::Course ) or IsEmpty ( Clips::Module ))]

Show custom dialog ["You must enter a course and module number when selecting E-Learning"]

Go to Field [Clips::Course]

Exit Script []

Basically, there's 3 fields, and what I'm trying to do is send the user back to the layout if: the 1st field has an entry of "elearning' (selected via a value list)

- and -

either of the second two fields are left blank.

So... IF field1 is "elearning' AND field2 OR field3 is blank, then fail.

I've tried several different versions of the calcuation:

Clips::Used = "ELearning" and (IsEmpty ( Clips::Course ) or IsEmpty ( Clips::Module ))

Clips::Used = "ELearning" and IsEmpty ( Clips::Course ) or IsEmpty ( Clips::Module )

IsEmpty ( Clips::Course ) or IsEmpty ( Clips::Module ) and Clips::Used = "ELearning"

(IsEmpty ( Clips::Course ) or IsEmpty ( Clips::Module )) and Clips::Used = "ELearning"

and a couple other iterations that I can't remember now.

What's happening is that sometimes the script will work, and other times, it won't. It's behavior is completely random. The data being entered into the fields is consistent, so I'm sure that's not the problem. I think the problem lies in the way I'm expressing my calculation or perhaps some other variable that I'm not thinking of that's allowing the script to pass over an empty field. I think I've usually noticed it happening when there's data in the 2nd field (course) and not the 3rd (module). One thing that I have noticed, is that when the script misbehaves, it's on FIRST data entry into the record. If I simply skip entering data in the 3rd field (cursor never even enteres the field) and try to run the script, it'll misbehave. (sometimes.) If I fill in the 2nd and 3rd field and then go back and make one of them empty before running the script, then the script seems to work every time. When the script misbehaves, the errant data (the empty field) IS intered into the record.

This is the last one of several script steps to validate a record entry before saving it and closing the window. All the previous steps work as designed by either: Opening a custom dialog, putting the cursor in the errant field and then exiting the script, or passing over the other "if" statements and onto the next if the criteria has been met. I've been over this with a fine tooth comb using script debugger and data viewer and everything looks like it's operating normally - it's as if the script is randomly ignoring the second field - the one after the OR operator if it was skipped over with the cursor during data entry.

The entire script begins with "Omit Record", "Show Omited Only" and ends with "Show All Records". I don't know if those steps are necessary or not, (I had a situation where a script was clearing the contents of a field in ALL the records until I added that step, so I figured I was protecting the other records in the DB) but it seems that maybe taking them out helps - I'm not sure yet, the script's misbehavior is so random, that it takes time to see if it's fixed. I thought I had it fixed earlier today, but this evening, it started acting up again.

Anyone have any insight on this? What's the "proper" way to write the calculation I'm looking for? Is there a difference behind the scenes between a field that the cursor has been in and been left blank and a field that was never entered? (I know that's a longshot, but I'm out of ideas!) What am I overlooking? Help, before I go bald!

Edited by Guest
Link to comment
Share on other sites

First are you certain that the fields are empty? Is there perhaps a space or a carriage return?

Second, try putting a commit record [] first.

If you indeed try all those variations then it should have worked for you.

Clips::Used = "ELearning" and (IsEmpty ( Clips::Course ) or IsEmpty ( Clips::Module ))

You can try

Clips::Used = "ELearning" and IsEmpty ( Clips::Course ) + IsEmpty ( Clips::Module )

Link to comment
Share on other sites

Hi john

Thanks for the reply

Yes, I'm sure the fields are empty - in fact, the script only seems to mess up if the field has not been entered by the cursor, but skipped over entirely.

I have a feeling the commit record step would work, because then I'm making the script go look at data that's absolutely been entered into the record rather than 'in stasis'. However, I'm hesitant to commit the record before validating any data entry errors as the window (where the data entry layout resides - it's a modal window) can be closed by the user at anytime via the OS's window controls. (thereby leaving errant data in the record.) But then again, this is a danger inherent to using modal windows, I guess.

I'll give your calculation a try and see if that helps.

Link to comment
Share on other sites

hmmm.

I disabled the "omit record" and "show omitted only" and have been playing with it for half an hour and it hasn't messed up yet.

John, your alternate calculation and then your commit record fix is on my list for next time it messes up.

Just out of curiousity, (trying to understand) ...using the + instead of the OR... what's your thought process behind that?

Link to comment
Share on other sites

It doesnt really matter if you use the OR. OR and AND test with a boolean.

By adding both isEmpty, it will return 0, 1, or 2. 0 is false, 1 or 2 is true.

Link to comment
Share on other sites

It doesnt really matter if you use the OR. OR and AND test with a boolean.

By adding both isEmpty, it will return 0, 1, or 2. 0 is false, 1 or 2 is true.

Thanks for clarifying! I was wondering because the + deals with numbers, but it makes sense now. So either the + or the AND/OR should both accomplish the same end result...

Math was never my strong suit, so I've struggled with getting the correct equations in place for what I want to accomplish. I'm still trying to figure out the difference between (), [] and {}

I understand what () does - that's a basic algebra thing, but [] and {}??

:P

Link to comment
Share on other sites

This topic is 5762 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.