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

Having trouble with constrain find in script...


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

Recommended Posts

Posted

I guess I spoke too soon about "understanding" the set field function. I am still having essentially the same problem. When it gets to Set Field [individuals::Month,Families:???_gMonth] in the Birthday script, it returns an error that says "No records match this set of find requests." When you look at the layout you can see that it is literally putting "=Families::_gMonth" or something like that in the field.

I am uploading another clone, in the hopes that you can spot my error. It is (I think) either in the way I am getting the data into the _gMonth field (Monthly Lists script) or in the way I am trying to get it out (Birthday List script.)

Thanks again.

P.S. In the one you sent to me, the script did not seem to work either.

Clone.fp7.zip

Posted

First: Check your calculations for the correct result type (drop-down box at the bottom of the dialog). Your Month is "Decemeber," but you have it set for "Number". FileMaker 7 is forgiving, but this can cause problems.

On that same note; there is some clunkiness in opening a new window with the Month,* in Find mode. The user MUST hit the Enter key, but there's nothing to tell them so. So a button would be good. Alternatively you could open that window in Browse mode, with _gMonth as the field, rather than the real Month, then Pause. In other words, set the global BEFORE entering Find mode; as it's the only criteria.

Then Enter Find mode (no Pause), set the real month to the global, and continue. The advantage is that nothing can go wrong; you can't hurt such a global field. Whenever you enter Find mode there is a slim danger that the user will somehow get into Browse mode and change data in a real field. Either way is fine, but put a button to Continue (Resume).

It is fairly easy to "reserialize" a table. There is an option in the Replace Contents command to do so. It can update the serial ID options (a checkbox in the dialog).

The problem is when there are related records. Just adding zeros (padding) to each will of course not break the relationship link between parent and child records; but anything else will.

It can still be done. I usually use a "dual" ID temporary structure. Replace the old ID in a temporary field, in both tables. Create a temporary relationship between them. Use that to reset the child ID to the new matching ID, a switcharoo.

As far as the Loop for deleting the Yahrzeit, be sure to work on a copy ???-|

*Also, as I said before. You can open a New Window with a name, size and position in one step. Yes, you need to Toggle Status Area [Hide], then Adjust, but renaming and moving a window afterwards takes extra time (unless you want to see it slide). No big deal, but smoother.

Posted

Basic Advice on Finds: If you are use global fields in Finds, don't try to put them in the Perform Find or Constrain restore settings. I don't know how (if any) field values can be included in those little dialogs.

This is how I'd do it (if the Month was to be chosen during the Find)???

Enter Find mode [Pause]

Set Field [ _gMonth, Month ]

Set Field [ Type of Entry, "Current Member" ]

Perform Find [] <- no Restore

This is how I'd do it in subsequent Finds (of if the global was chosen first):

Enter Find mode [] <-no Pause, no Restore

Set Field [ Month, _gMonth ]

Set Field [ Type of Entry, "Current Member" ]

Perform Find []

No Restore, no Constrain, only 1 Find operation. This is the "old school" way. It also lets you clearly see what the requests are.

(P.S. Look at the B-day script in the file I uploaded earlier. You must have missed it.)

Posted

I have fixed the new window/name window/set window issue on all applicable scripts. (I guess the tip didn't sink in the first time. I was probably too focused on something else... wink.gif )

I went with the Browse _gMonth idea. I can see the advantages of that big time.

I added a button to resume the script. (It is just a grey blob right now. I want to figure out how to make a "Continue" button that has the aqua interface. I may just screen capture one...)

I checked the calculations, they were both listed as numbers, they are both changed to text. I checked the actual data in the tables, it is listed as text. Still the same problem...

The anniversary part works. The birthday part returns the same error.

Posted

OK, I looked at yours. Your Perform Find still has Restore. Uncheck it.

Here's a file that has the loop to Delete Y's. Actually it has 2: one just marks them as obsolete, the other deletes. I think marking is probably better; the Loop is far simpler; you can look at them again before deleting.

Synagogue6.zip

Posted

WORKING!!! - For some reason, I had some values in the Enter Find and Perform Find command lines... Once I made sure those were all empty, it seems to be working now. Looking at your tips above, I said to myself, "Hmm, what's the deal with the specifying "Perform Find [] <- no Restore" and "Enter Find mode [] <-no Pause, no Restore." When I checked my Perform Find, it had some stuff in there already. (I don't remember putting it in, but I have been working on this into the early hours of the morning.. crazy.gif)

I didn't miss the BD scrpit - that is where I got my "enlightenment" on the whole set field issue. (Sometimes you just can't see something until it really, really applies to you wink.gif )

I am going to test it a bit more, but I think that was the issue.

On to the next thing. And thanks again!!!!

Posted

Okay, so it is working beautifully for Aniversaries and Birthdays, but now, trying to replicate the whole deal into the Yahrzeits, I am getting errors again.. I even tried deleting the Yahrzeit script altogether and rebuilding the steps in the Monthly lists script (after all, you will never run the yahrzeit script except as part of the monthly list script, so there was really no need for two seperate scripts...)

It works until I select the "Continue Script" button in the pop-up window, then it says: "There are no valid criteria in this find, type a valid request before clicking Find." Of course, that is not very far in the script.

I have checked the field definitions (both text). I have checked the Enter Find and Perform Find commands, they are empty and Restore is not selected.

How am I getting this so wrong???

I am sorry to be so thick on this one. Clone attached -- if you haven't thrown up your hands on me at this point...

SynagogueDatabaseClone.fp7.zip

Posted

Aaargh! I could not see anything wrong; until I checked the obvious. _gMonth is NOT a global field (that'll get you every time). Make it a global field.

Posted

SO, SO, SO SORRY!!! I knew it was a simple little click somewhere... I didn't mean to waste your time. Well, I guess I learned THAT lesson...

I got the reserialization (is that a word?!?) done. It required some concentration, but it went off smoothly.

Next is the delete family script and then maybe (if I can stand it) I will change those committees to a many-to-many relationship, now that I have been coached by the best!

I am going to show it to a Board member in an hour or so. Of course, she will have no idea how great it is. It just does what it seems like it should , right? I guess that must be how all you REAL developers must feel all the time! smile.gif

Posted

Take a look at the Delete scripts in my file. I recommend the ObsoleteMark rather than delete. Much simpler and safer. Of course then someone has to look at them sometime.

A developer gets most of their satisfaction from getting it to work in the first place. But users do appreciate it; there is quite a lot of clunky software out there, so a well-designed interface is noticed. They also however tend to spot anything that is still clunky in your work. This is good really. It keeps you looking for better ways to do things.

They don't seem to really appreciate nested loops with relationships, multi-line keys, etc. quite as much as we do :-]

Posted

Okay, I have been busy putting everything you've taught me to work by creating a Committees table, Join Table and related records and files. This will replace my (clunky) committees field as suggested days ago in this thread.

The clone attached is not tidied up yet, but here is what I am attempting:

I am trying to put a container field OVER the dropdown arrow. This container field would perform in the opposite way from the other two. In other words, when the portal row is empty the container will show the graphic (a little plus sign). That way, when you look at the portal row, an empty row has a plus sign (to add a portal entry.) I think it will be just a tiny bit more intuitive, but of course, it is not working the way I thought it would...

The _gPlus and _cgPlus fields are on the join grapics © table and I think they are all set up right. When I copy (layout) and paste (browse), nothing shows up in the box, but then again, I wouldn't expect it to because THAT entry does have an Iid.

So what do you think? Is this just not possible?

P.S. The Board member was very impressed. Of course, I told her that I had a lot of help!

SynagogueDatabaseClone.fp7.zip

Posted

Something like that is possible. I've done it somewhere before. I wouldn't necessarily put it over the arrow. Remove the arrow; it's just a graphic, not a field. Sounds like you want a calculated "+" to replace the arrow. If you look at the calculations for the arrow, you basically want the opposite; if the serial ID is empty, show the button, otherwise not; uncheck "do not evaluate if fields are empty" (or whatever it says down there), if necessary.

But now I believe you've disabled full access for the Guest account, so you'll have to tell us the Account name and Password.

Also remember the Join Graphic layout belongs to the Join Yahrzeit table. It's not just global containers, it's calculations also. So you can't use it for other tables. Calculations belong to their own table; they have to check if something is empty or not.

I'm probably not going to be available much this evening. I've been working on my Golf scores solution. It's quite the burnout; taking a short break.

Posted

Oops, I forgot to re-enable full access to the Guest mode. Did that. I think I may just leave the drop down arrow. I just thought it would be neat if it "changed" from a plus sign to an arrow depending on whether on not the field was empty...

I recreated the whole Join Graphic layout, so that Join Committees would have its own. I didn't figure that out until I started plugging in some data and noticed that some people just didn't get a trash can/arrow. (Of course, they were the ones without yahrzeits, so it wasn't to hard to figure out why...)

I have moved on and am trying to work on the script to make the labels for various committees (based on the scripts we were working on earlier today.) Why this is so difficult for me, I have no idea, but I am getting bizarre and unexpected results. It is returning random children only...

Good luck with your Golf scores solution. I find it amusing that to "take a break" from something that is difficult for you, you turn to my little database problems!! smile.gif

Thanks again for all your help. I really feel I am nearing the end here. Clean up the committee labels, add the delete family/mark yahrzeit script, work on my accounts (this will ultimately be networked between 3-4 computers), and troubleshoot one last issue with the yahrzeit printing.

You probably know the answer to this question off the top of your head and I am dying to know the answer - When I set this up at synagogue, the database will live on the computer in the main office. The Rabbi and Religious School coordinator will access it remotely. You may have noticed the "Rabbi's notes" and "Religious School Notes." These are intended to be confidential note files that can only be accessed by those individuals respectively. (They pop up via script.) I have double checked that they are not accessible if you don't log in under the right name. (Ie. Only the Rabbi has access to the Go to Rabbi script/layout/field. What I don't know (since I don't have FMP on two networked computers is if the following is true:

File opened on Office computer (without access to Rabbi stuff)

Rabbi opens remotely using Rabbi login (which gives access to Rabbi stuff)

Will Rabbi be able to access scripts/layouts/fields if Office is not...?

This will be easy enough to test once I get the whole system in place, but this database is one small part of converting the whole place over to Mac. (I started this by just making sure that I would be able to recover the data from Access before we made the switch...)

SynagogueDatabaseClone.fp7.zip

Posted

I was taking a break from all computing. You're hopefully not still there. But a quick note, for the morning. The plus button doesn't work because its global field is not a container, but is text; can't paste a graphic in a text field. You have to copy/paste these things in you know. I can't tell whether you have or not, because you only upload clones. It would better to upload a file with just a few fake records; because otherwise everyone has to redo all the globals, if they want to see. It doesn't much matter to me; I know where they are.

It works, and looks good. You want to make the field big enough, 2 pixels wider and taller than the graphic (for now; it's kind of a bug). I set mine to Center on both directions, and Crop. There's no need for Reduce and Enlarge on an icon.

Lines on 4 sides, set to none; that allows it maximum fill.

As far as remote access, I don't think it much matters what access the local file has when you log in remotely. FileMaker logs in with the external Account. It would of course be much better to be running Server on a dedicated machine. But I imagine with the light load and the low budget, regular FileMaker will do.

You want the files opened first, and left open on the main machine, for remote access. Difficult to open remotely if they're closed; unless you use something like Timbuktu. Do NOT turn on File Sharing for the OS. They should ONLY be able to get to the files via FileMaker's Open Remote (or an Opener file with that step). Do open or create an opening for port 5003 in the Firewall. It is not there by default in OS X (or is this Windows? doesn't much matter, both need port 5003). It's important that this is set up correctly.

Posted

Sorry that I seem to be so sloppy about checking those global/container files. I got it working and like it. I think it is a tiny bit more intuitive.

My Committeess/join committess is working like a charm. You can add to the committees from either direction.

I fixed the label problem. The script, globals, etc. were all fine. I forgot to make a labels layout that pointed to the Join Committees table instead of the individuals. It really is quite a complex task making these things run properly...

So, I am left with three small problems to fix:

1) Is there an easy way to make a "back" button? On that takes you to the previous layout? You might get to the individuals list many ways and want to go right back to the layout you came from... It doesn't seem to be an option in the dropdown list for Go to Layout. I would have expected an option like Go to Last Layout right under Go to Original Layout.

2) I am making a backup script to run automatically on close from the "Office" account. (It will check the computer/user name.) I know you can set the file name, but can you (a) calculate the file name - ie SD backup "current date".fp7 and can you (: make it only backup when a week or so has passed. (We don't change the data that often...)

3) This one is the most complex: In the Jewish calendar, we have what is known as a leap month. Some years, we have Adar. Others we have Adar I and Adar II. For the yahrzeith list, in a year that has only Adar, all the yahrzeits (Adar, Adar I and Adar II) are observed on the coinciding day in Adar. In a year that has Adar I and Adar II, the yahrzeits for Adar and Adar I are observed in Adar I, and only the yahrzeits for Adar II are observed in Adar II. The way the print/list script is set up now, it works for Adar (finds all with Adar, I and II and sorts by date) and Adar II (finds only those with Adar II), but Adar I returns data from Adar I and Adar II, instead of Adar and Adar I. I know this is because of the way Find works, but I am wondering if there is a way to write a subscript for Adar I that would magically produce the right lists...

Thanks again for all your help. This has been a great learning experience for me -- actually, it's been a great experience all around.

Posted

1) No, no easy way. Basically you can set the name (or number) of the current layout into a global field EVERY time you leave a layout. Then your back button would use that. This means ALL navigation must be scripted; which it seems that it is.

Another possibility is to put buttons on only certain layouts, which have an obvious connection to another. This is usually what I do; because I don't want to deal with the above. My arrows in the portals are an example.

Your solution has a "menu" based navigation, in that clicking the icon returns you to the "menu" page, then you start off again. Another alternative is the "tab" based navigation, with a fairly uniform group of tabs on most layouts. Works fairly well on most solutions; but is more work; and a different layout look entirely.

Ideally you might have all of these systems. But that's a lot of work.

2) Is this on a Mac? It is more difficult when you're running plain FileMaker. Server can do this properly. But in either case you'd need to do something to save dated backups. Generally people use Server to do a backup, then have a dedicated backup program backup those files to another disk. But NEVER let a backup program touch the live files.

In your case, with plain FileMaker you would need someone on the host machine to run the Copy As script. It has to be the host computer (which has to ALWAYS open first anyway).

[it could I suppose be scheduled with an app like Cronnix, which can call an AppleScript, to tell FileMaker to run the script.]

FileMaker would Copy As to a fixed location, then a Perform AppleScript step could move/rename the file. Needless to say, you don't really want this to happen while people are working much on the file.

Easiest is to run the script, with the Perform AppleScript to move/rename afterwards on opening. It's not hard to set the date into a global, then check to see when it was last done. People would have to wait until it was finished. But with a small file like this it wouldn't take long.

3) Do you know whether you're in an Adar I & II year? If so, how?

In any case, you can add requests, use "exact" Finds with "==", to deal with it. But if you knew which kind of year you wouldn't need all 3 choices in the value list; just "Adar", let the script add what's needed. Otherwise does someone know which Adar they want?

Posted

Ideally you might have all of these systems. But that's a lot of work.

That sounds like way more than I want to bite off. If it was easy, (I thought I might be missing something basic) I would want to add it. but basically, you might end up at the Individuals List from a variety of ways. They will just have to click around. This is still SO much better than what they currently have in place.

In your case, with plain FileMaker you would need someone on the host machine to run the Copy As script. It has to be the host computer (which has to ALWAYS open first anyway).

FileMaker would Copy As to a fixed location, then a Perform AppleScript step could move/rename the file. Needless to say, you don't really want this to happen while people are working much on the file.

Easiest is to run the script, with the Perform AppleScript to move/rename afterwards on opening. It's not hard to set the date into a global, then check to see when it was last done. People would have to wait until it was finished. But with a small file like this it wouldn't take long.

Ultimately, this will run on a small group of networked Macs (3-4). I currently have the on close script set to run only when the User is Office (the main computer where the file will reside.) It simply prompts a Save As dialog. I may try to add in the Applescript, but I know even less about Applescript than I do about Filemaker.

3) Do you know whether you're in an Adar I & II year? If so, how?

Me, personally, I don't know. But it could easily be looked up for the next 20 years or so.

In any case, you can add requests, use "exact" Finds with "==", to deal with it. But if you knew which kind of year you wouldn't need all 3 choices in the value list; just "Adar", let the script add what's needed. Otherwise does someone know which Adar they want?

This makes a lot of sense. I have to think through how I would get it to do that. Something like:

If _gMonth = Adar

If get (current year) = Adar only

set _gMonth = Adar

Else

set _gMonth (what here? ==AdarI?)

(how to I get it to add the Adar yahrzeits here? - expand find ==Adar?)

do all script stuff

set _gMonth, Adar II

do all script stuff

End If

End If

I am assuming a put another little table in to check if it is an Adar only or Adar I/II (Leap) kind of year?

Posted

The following years are leap years: 05, 08, 11, 14, 16, 19, 22, 24. (I looked it up using Hebcal.com) If I remember correctly it is a 13 year cycle with 7 leap years. (What can I say...) Leap years have the Adar I/II. Regular years just have Adar.

There are entire books written on the Jewish Calendar...

Posted

The AppleScript is fairly simple. I'd be glad to do it.

It seems to me a simple calculation could tell you whether it was a leap year; for quite a while.

"==Adar"

would be an exact find for only "Adar"

So you'd look at _gMonth with a Case ( ) calculation, then build the Find request accordingly. To find Adar and Adar I, you could use 2 requests with exact criteria; or you could just find "Adar", to get them all, then omit "Adar II".

Posted

My husband is kicking me off of my computer to transfer all the data to my new Powerbook. (He does not trust me to do this operation by myself. - He is not willing to risk that I might lose this database and then he would lose me for another 2 weeks.) I may go through withdrawl.

I am eager to get working on the Adar problem. I will let you know when (realistic) I run into problems. It is still fuzzy. And now I have to look up the Case function!

Thanks.

BTW, they are really blowing me away on the Hebrew calendar. (In Brain Food.) I feel like I have an army of experts helping me out. This really is a great place. Can I move in?

Posted

You seem fairly capable; but heck, if he wants to do it....

I have the AppleScript to rename the backup; just waiting on your next version. It's getting difficult to keep all the updates synced; some features are in one, some, but not those, in a later.

BTW, you need to keep those container fields the right size; don't squish 'em; 1 pixel on a side bigger than the original layout object (this is a bug in 7, may be fixed; used to be exact size would work). I use the Crop option myself. Small icons look best just as they are.

This is what a Case would look like to "mark" a leap year; it's a simple one. I added a Let() to shorten it. You would put this in the script, to fork to a different action. If it's a calculation field, it needs to be "do not store."

Let (

date = Get(CurrentDate);

Case (

Year(date) = 2005 or Year(date) = 2008 or Year(date) = 2011 or Year(date) = 2014 or Year(date) = 2016 or Year(date) = 2019 or Year(date) = 2022 or Year(date) = 2024;

1;

"")

)

One thing to know about Case: it stops at the first true result. So you can "stack" the answers.

Posted

Coming right up.

I added a record or two for you this time.

I just got my computer back. I am capable, but sometimes you just have to let the man be manly. For him, upgrading computers is a man job. What can I say...

I have to go to work (real work - where they actually pay me) this morning. I am going to take my computer with me and try to get satrted on this, so I eagerly await your response.

SynDB.fp7.zip

Posted

OK, I've put all the features from all the versions together in this one. So, if you've been working on another, please either transfer your new work to this one, or transfer ALL the features to yours. But please don't post a partial file.

I came up with a new idea for the Yarhzeit month problem. You need 2 different value lists, 2 choice layouts for the month. The script checks whether it's a Leap year, then goes to the right list.

Then the Find part of the script adds what's needed to find the right Adar (if any).

There's a 3rd "all" list, for data entry. Though even that could toggle, if you knew the year.

My AppleScript rename-the-backup script is installed. But it only kicks in if the file name is "Synagogue.fp7" It doesn't if there's a version name on the file (which I put 9, so I could tell what's what; I had 3 files).

I set the backup file name to be "Synagogue_bak.fp7" That name is something that can't be scripted, neither can it be passed directly to AppleScript. So one has to decide on a fixed name if you expect AppleScript to find the darn thing. If it does find it, it would rename it to "Synagogue_bak_12_30.fp7" today.

If there's already one of that name it won't do it, but will tell you so. It could alternatively delete the existing one first. But it will still backup; it just won't do the renaming. This is something to decide and fine-tune I guess.

There are 2 extra fields on the "main" layout, the backup file filepath (calculation) and the current month & day calculation. The have white text, and non-enterable; but they have to be there, so AppleScript can easily read them.

I changed your conditions for backup. CurrentUserName is not very good, as it belongs to the computer, and can be easily changed. I used PrivilegeSetName. It's more reliable. It checks whether it's the host computer with Get(MultiuserState).

[There's also a field in the definitions, so that it could zip the backup, using a "do shell script" step; that seemed like overkill, but I left it for general interest.]

Synagogue9.zip

Posted

Okay, so, while you did all that, I was proud of myself for fixing my little label printing problem (it was only printing 9 labels per column instead of 10). That would illustrate the difference between "beginner" and "advanced" users! grin.gif

I will definately go with putting my data/changes into your database! It is going to take a while for me to sort through and understand everything that you have done. I will probably tweek the delete family/mark yahrzeit script as there is at least one other thing I want it to check (if there is a "location," we will keep it.)

I also think I figured out a more elegant way to move a child from one family to another for when they grow up and become their own member. - make new family record, change Fid of Indiv. record through a custom dialog box, change status. (Right now, I make the user go through this whole rigamaroll involving TextEdit.)

I will also try to add the hebrew date calculator that -Queue- and comment have been working on so furiously.

I guess you won't hear from me for a while, as I sort through all of this, but don't think that I am not working on it!

Thank you, thank you, thank you.

Jessica

Posted

I have been pouring over the file you uploaded. I noticed that on the Delete Family Mark Y script, the first command is "Commit Records/Requests [No dialog].

I am wondering what the rational is behind that. Is that a step that I should be adding to the beginning of a lot of my scripts?

  • 2 weeks later...
Posted

The Commit Records/Requests step is equivalent to clicking out of the record. It commits any changes that may have been made on existing records and establishes new records as part of the file. It is also sometimes necessary to use when setting key fields for relationships. Overall, it's a good step to start with and put after vital Set Field steps to ensure that your script performs as it should.

I often add a test for an error after the step, which means that the record cannot be committed due to invalid information being input, such as text in a date field, etc.

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