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

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

Recommended Posts

Posted

Hi - this is from a previous thread "script to change Y/N fields" - to clarify:

Properties file has a portal which displays images for that property based on the relationship propertyID::IPropertyID. The ::Image (s) displays in the portal. What I would like to do is be able to script a "set as default" button next to the image(s) in the portal so that the user can see all the images for that property and set one of them as the default image, and have the changes recorded in the images file (default image?=Yes, all other images for that PropID show default image?= No).

I already have rlnshps (and fields) in both files (maybe it is unnecessary to have them in both files) relating PropID::IPropID and DefaultImageID::IDefaultImageID, also a field in both files called DefaultYN and IDefaultYN respectively.

One question is what type of fields all these should be. Another is whether I should have a rlnshp between those last two and in which file.

I also have a container field in Images DefaultImage so the user can see what the current default is. No relationships for that one yet either.

Making the fields calculated (or not) as follows (as suggested by Paolo) does not work but I cannot figure out why.

DefaultImageID in Properties is text

IDefaultImageID in Images is calculated Status(CurrentRecordID)

IDefaultYN in Images is calculated If( IDefaultImageID::DefaultImageID = DefaultImageID, "Yes", "No")

Also, very few of the options for the fields have been set while I try to figure all this out.

The script for the "select as default" button in the Prop file is (thanks Paolo):

SetField( DefaultImageID, DefaultImageID::IDefaultImageID)

Enter Preview Mode []

Enter Browse Mode[]

None of this works and I have tried changing calculated fields to text and using value lists (and back) and I can't figure out why.

I hope someone can help - my fragile little newbie brain is hurting - confused.gif

Thanks, Bonnie

Posted

Hi,

Ok, I readapted one of my files including an image container within the adress file.

Check what happens...

I'll soon drop a sample of how this feature could be a real (IMO) treat in a user interface...

Hope this helps...

DEFAULT.zip

Posted

Ugo don't you ever sleep? Ma grazie tantissimo!!! I will give it a try. Will try anything after spinning my wheels all day ... Bonnie

p.s. what's an IMO? I am too crispy to figure that out too.

Posted

Password : UGO...

I was watching Milan AC - Inter (European Soccer championship demi-final). At least I know there will be an Italian team in Final grin.gif

Posted

Works fine for me. Anyway, I should say, as I already said in your previous post that the sample is based upon renumbering portal.

As this file wasn't only dedicated to this feature, it has plenty of other fields that may confuse.

So when you have seen how it works on my files,

the best thing is to go to the sample section and upload DJ's Renumbering Portal sample. The only thing needed is to create a container field in the main and have it lookup the value from the related that just have been renumbered to come to the front of the relationship.

Posted

I have looked at both of these files and I do not understand the need for a complicated scenario which moves records up and down a portal and constantly renames them. It just seems unnecessary. All those fields prev, next, current - it is way too complicated for my purposes.

Maybe I should be posting this in the Calculation forum? Ie. 4 images are allowed. They are 1,2,3,4. If image 1 is chosen as default, then images 2,3,4 are changed to Not default. That is all I need ...

Can anyone help with a simpler solution than DJs? I have been at this all day ...

Also I can send my files if anyone is willing to see what exactly is wrong with my current setup/relationships/field definitions...

Thanks confused.gif

Posted

Here's one way to do it, attach this script to a button on the portal row:

Set field (images::default image, "yes")

### my preference is to use "1" but it's not a big deal

Go to related records (show only related)

Go to related records ()

### yes, you GTRR twice, the second time puts you on the selected record

Perform Script (External, images, see below)

Go to field ()

### the step above is simply to bring you back to the main file

The images script:

Omit record

Go to record (first)

Loop

.. Set field (default image, "no")

### my preference here would be blank: ""

.. go to record (next, exit after last)

End loop

Posted

How about you create a field in your photos file "DefaultImage" which contains either Yes or No. Then, in you parent file where the portal is, you have the portal sorted by a value list which contains:

Yes

No

That way, the "Yes" image will always be at the top of the portal - and if its a 1 row portal, then thats what you'll see.

To change which image is the default, you should create another layout, identical to the main one, but which shows multiple rows of the portal, with a scroll bar, and the image fields smaller - so you get a thumbnail list of images. Then create a script which when you click on the image, sets all the other related::images to "No" and the one you clicked to "Yes".

Posted

Hi all,

Ok , let me give some hint here as I received the files.

Well in some occasions, it could be interresting to renumber the portal rows and therefore pick up just the default "record" from the related file, by a simple toggle up/down (after a certain amount of settings in the related file).

In other occasion, and if like in this case, it is likely that the image or data would not be used accoss different database as a default record to be looked up, a single calc in the related file Case(yes/no, Record_ID, "") and a Case(yes/no, Image, "") would be necessary.

Then we'd use a related field in the main, using a new relationship using the Main_ID for left side and the Case(yes/no, Record_ID, "") for the right side.

Now the script would go

GTRR

Perform external script

where the external script would simply toggle the yes/no or the 0/1.

I too prefer the simpliest toggle setfield (num fied, abs(num field -1)) as it is also attached to a "toggle container checkox).

Of course, in this case, if more than one photo is selected, you'd run into problem as there would be more than one relationship. So just use another script which loop through the related records, reset all to 0 and just select the one you wish with a 1. Or use some other script in the portal.

Posted

OK you guys, here are the files. I was busy trying Tom's solution (which spectacularly did not work, it even cleared my portal shocked.gif), then Russ wrote, and then Ugo (you're still awake? laugh.gif)...

I know I am a newbie but there must be a simple way to fix this ... can you believe I have been working on this same thing since 9:30 AM (ok, I was working on one other thing as well, but I didn't solve that either --- see the "select button on a list layout" thread frown.gif

Hope the files don't take too long to upload.

Bonnie (can I have a glass of wine yet?)

Posted

You have your "Properties" file which displays images from your "Images" file based on the PropertyID::PropertyID relationship. If I understand your question correctly the following could be a solution:

In "Images" file:

Create a self join in your "Images" file of PropertyID::PropertyID (Well call this relationship R1)

Create a number field called "MyNumber"

You already have your container field called, for example, "BuildingPic"

Create a calculation (container) field called "DefaultPic" as follows: If(Max(R1::MyNumber) = My Number, BuildingPic, "")

In "Properties" file:

You have a relationship already to the "Images" file which we will call R2

Create a script (Called S1) as follows: Set Field [R2::MyNumber, Max(R2::MyNumber) + 1]

Place a button (S1) on your portal - this will make this image the default image. You could also create a text calculation in "Images" that returns the result "Default Picture" under the same principle as "DefaultPic" was created. Or how about creating another container calculation that returns an image stored in a global field that shows, for example, a thin blue line around the picture in your portal? See attached file.

Pete

Posted

I see that the file you attached has been downloaded a bunch of times by now, but from the first time I tried (maybe a 1/2 hour ago) I got a "page not found" error each time, and still now even though I rebooted. Would you mind emailing it to me at [email protected] ?

You guys are good. Each different solution I hear about makes my head spin a different way. This is my first database. All I want is for the damned button to work. It's amazing how many ways it can.

Very extra crispily yours - Bonnie

Posted

Pete,

It shouldn't take too long (hey - thats one snap happy real estate agent you're talking about)... The process in my files works on 2 Finds performed via an external script - but the finds are all on indexed text or number fields and the child file never shows. I guess the replace of "No" could take a few seconds for 1000 records - but if you've got 1000 photos to deal with, then some things are going to be slow... like getting them off a server and across a network.

Just tried it on a file with 2100 images and it took 3 seconds. Mac G3 400MHz Powerbook. FMP 5.0.3. OS 8.6.

Are you up early or up late :

Posted

You guys are so fast I can't keep up! These things are coming in so fast I can't even try them ... plus I had to go and change my email address to my most direct one so this will happen even faster (you guys aren't going to spam me, right? cool.gif only kidding) Russ, thank you for your email, your solution is SOOO easy ... I haven't received/been able to download Peter's yet due to an apparent malfunction on the page (but Peter, to answer your ? above, the users are allowed only 4 image files per record, at this time, and I can't see them requiring any more than, say, 10 max!). And then Ugo, who apparently does not require sleep, sent me my files back AGAIN via email and I need to rename/open them and see what complicated and elegant thing he has crafted (which always goes over my head but, I have to admit, accelerates my learning curve).

Maybe tomorrow I can make the button work?!

This has taken all day, but it's been worth it! What a bunch of lessons (and characters) you guys are!

It's late here and you are sending things fast and furious ... I'll take a look at everything and get back to you (it's ironic - I'm the LEAST qualified to make this decision about which solution is more elegant and simple! LOL! so much for someone doing it for me - you ALL did it for me and now I have to decide! LOL again!)

laugh.gif Woohoo You Guys Are Great - The Best

Ciao for now - Bonnie

Posted

Peter, I still can't download your file, can you email it to me please ...

Thanks - Bonnie

p.s. if I'm going to keep up with you guys I'll be working on adrenaline and cigarettes too - it's almost 11:30 PM here and I have to spend tomorrow (all over again) trying to make this s** work ... what a drill, for my first DB! Feels like boot camp.

Posted

I did email it 7 minutes after you posted your message.

I emailed to your email address provided. I will try and attach it again to this email. As I said I could open the download from the link.

Pete

Posted

Thanks Pete, I finally got your mail/files and responded (but that link on the forum - above - still didn't work).

At this point (late at night, have been working for 15 hours or so, and that's minus interruptions). I'm ready for a glass of wine and bed. Tomorrow I will look at the 3 or 4 different solutions but I feel very unqualified! You guys are the experts!

I will report back tomorrow. This is like a contest where a complete moron has to determine which of Einstein's alternate theories are the best. But, tomorrow, I will tell you which one works first (and/or easiest) -- OK? (assuming one does!)

In all likelihood I'll be writing to say I got 95% of it finished and can someone help! LOL!

Ciao - Bonnie

THANKS YOU GUYS - YOU ARE THE BEST

Posted

Hi all,

Am reporting back as promised. I finally got my glass of wine last night, then crashed and burned, dreaming of "set as default". Once regaining consciousness, spent 2 hours this AM looking at everyone's files (Ugo's, Russell's, Peter's), finding my favorite(!) solution, and then fixing my own files (mostly they're fixed ... told you I would write back saying mine was only 95%!! grin.gif)

Drum roll please ... Russell's solution (see post 66035 above) was perfect ... easy, simple in design, etc. Of course it works perfectly in his files. In mine it works 95% perfectly. I've attached the files (mine and his) and am hoping you guys can help me figure out why these things are happening in mine (things which don't happen in Russell's files):

(Note, these things can be seen for property #1005 which is the only one I have 2 images to test things with. The B&W should be the default, and I tried to change it to the rendering, but you can see what happened - I left things that way when I zipped it.)

1. In the Properties (main) file, clicking on another image to set it as the default causes 2 "are you sure" screens to appear (which I would NOT like users to see).

2. The DefaultYN field is changed correctly in the Images file (from No to Yes, and vice versa), but in the Property file, the correct image is NOT displayed.

3. And, as an annoyance, the Row Color thing which works so well in Russell's main file will not work in mine. I think it's buried in the back layer or something, but I'll have to ungroup the fields that make up the button to try and fix it.

Any ideas? I'm going to now work on something else (after spending a day and 1/2 on this "set default photo" thing! tongue.gif

Ciao for now ... Bonnie

p.s. THANK YOU THANK YOU THANK YOU !!!

Posted

Sometimes I get "file not found" when I try to download attachments, so I can't see your file right now. I'd like to make a couple of comments:

Peter's method is very clever and elegant. It's outside the box thinking, that is: he doesn't bother to try and clear the field or set it to "no" for the pictures not chosen. Instead, he simply sets a number field to Max + 1 -- this makes the number unique for that related group -- then calculates which record contains the new maximum value. Nice job, Peter!

Russ's method is essentially the same as mine, except he sets ALL the related records to "No," then goes back and finds the desired record and sets it to "Yes." Whereas my method sets the desired record to Yes, then omits it and sets the remaining records to No. He also uses Find instead of GTRR, for some reason. His method works fine, and might be slightly easier to mentally digest.

I've taken the liberty of modifying Peter's file (Peter, if that's not OK I'll remove the attachment) just because the pics are nice and you can compare the scripting methods side-by-side. My original script did have one problem, which is the second GTRR turned out to be unnecessary -- it seems to me I've had to do it that way before, but in this case not. I felt compelled to defend my script, what can I say?

As for your current problems:

1. "are you sure" screens...

There's a checkbox for the Replace script steps, Perform without dialog.

2. ... in the Property file, the correct image is NOT displayed.

Russ's relationship to display the photo is dependent on a Sort order, go into Define Relationships and take a closer look.

3. ...the Row Color thing ... I'll have to ungroup the fields that make up the button to try and fix it.

Of course, you'll want to make a duplicate of the group first so you don't lose the original button script. I'm wondering if maybe you don't have the global container and calculated container fields set up in the related file?

Posted

G'Day from the Land of Oz...

The Row-Colour thing is a calculated container field in the child file, which makes the container field for the record the colour of a global container field (green in my example), if the DefaultImage field is "Yes".

I agree that Pete's method is more elegant and makes better use of FMP's relationship capabilities, and yes Tom, I probably should have used Go To Related Record.

Bonnie - I guess the things to come out of this are:

1. The post in which I put up my answer started off with - "Here is how I'd do it" (emphasis on "I"). FileMaker is generally so flexible that you will find more than one way to solve/approach your requirements.

2. One of the great things about these forums is that you will get to see all the different approaches, and learn from them - I do...

3. The important thing is that you end up with something that works, meets your requirements, and (most of all) you can understand and replicate or build on in future.

Posted

Hi all,

24 hours later....

2. One of the great things about these forums is that you will get to see all the different approaches, and learn from them - I do...

3. The important thing is that you end up with something that works, meets your requirements, and (most of all) you can understand and replicate or build on in future.

AGREEEEEEEEED....

Pete, your file and method are excellent. So you came up with this after a week of coffee grin.gif.

Well considered, in Bonnie's requests, yours was the most accurate. Soory for the others. wink.gif

In other case, if you were to move a bunch of related informations (not only an image), you would however need a bunch of Set Field script steps, or transfer the Image_id into the Main file and use related field (or lookup fields ) using a relationship Image_Id ::Image_Id.

The disadvantages of such a method are that when you'll have to deal with a relational database, and transfer some information from files to files, you would always need to "tunnel" the image_ID (in that case, any other foreign_Id in other case) to have accurate results.

In these situation, I feel like a Renumbering Relationship Method would be more convenient, as the default settings would could along automatically using the Main_Id, either related to the Property_ID in the Property File, or the Property_ID in the Image File.

Posted

Hi again - As always the comments you guys have are right on. I should have elaborated more on how elegant Ugo's files were (but they were overkill for my needs, as he also said above) and how easy and brilliant (not to mention good-looking and fun) Peter's were (just like you, right Peter? smile.gif). It's just that my users "need" to see "Yes/No" (that's what they're used to), so Russell's solution worked perfectly for my needs. And what a great education to see all of them!

Also, I couldn't agree more that "the important thing is that you end up with something that works, meets your requirements, and (most of all) you can understand and replicate or build on in future". In my case, this DB is only part of my job, and I'll have to customize it further in the future (a lot further) so it's important to be able to remember what's going on in each file - ie. it needs to be very simple. Also, someone's going to inherit this down the road, at the company which will be using it - the old "what if I get hit by a truck" issue - ie. it needs to be simple ...

Back to the files: Thanks for the tips, Tom, I was rushing through and had overlooked the "perform without dialog" and the sort order in the relationship when replicating what Russ had done, and that solved problems 1 and 2. Re: problem #3, I had made a tiny mistake with the global field (color was in the wrong global container) but fixing that did not solve the problem. I have checked and re-checked the field definitions/calculations for those 2 fields - they look a little different in my files vs Russell's but maybe that's because FM6 on Windows looks/is different from what Russ is using? ... at any rate I am going to have to take apart the stuff in the portal (I won't forget to duplicate the button first) and find out why the color won't display, I think.

I'm not inclined to mess with the GTRR vs Find in the script, at this point, because it's working, but either one makes sense to me ... probably GTRR is faster?

If you figure out what's going on with the portal color (Row Background) let me know ...

Thank you again! - Bonnie

p.s. I loved how Peter used Ugo in his file grin.gif pretty funny! Check it out Ugo

p.p.s. I can email the files if you want to take a look, I didn't want to upload them again

Posted

Hi Bonnie,

About me and Cameron, how could he know. Nobody never saw us in the Champs-Elysees. grin.gif

Yes I admit she not only is the Real Estate seller....but Pete, you should have asked before giving these kinds of secrets.

About my home....hmm. Again, how could he know ?

There must be aguru there in Cap Town Pete !! laugh.gif

Posted

Hi There All

Firstly, Fitch - ofcourse its OK - It's always nice to see alternative methods for resolving issues.

I was recently working on a database for my office when exactly this type of scenario Bonnie is trying to achieve presented itself. In my case I have an email/message centre which looks much like Outlook - I wanted the chosen folder in a left portal to be highlighted and the chosen message in a right portal also to be highlighted. I started with scripts based on the principle of clearing a field in all related files and setting one as default. The nature of those scripts created to much "redraw" on the screen and was not instant. The solution using max is only replacing data in one field - even if there are a million records. The script now has very little redraw effect. For those who are interested I have attached a screen shot (Note: it is incomplete - but the effect of seeing the "default" folder and message is clear)

Pete

Edit: Just seen all posts come in while I have been writing above. And yes I have just woken up (It is now 12.45am here) - so I am armed with 120 camels and I am already on my 3rd cup.

Posted

Hi all - I just wanted to say that this exchange not only solved my problem but also advanced my FM knowledge base exponentially. laugh.gif

I still think Russell should post his files (attached up above in this thread somewhere) onto the samples page, as a very simple (for the users) solution to this, and Ugo should post his files (up above in this thread somewhere) as a very elegant solution to a more complicated scenario, and Peter! his files should also be posted because they are almost as user-friendly as Russell's and as elegant as Ugo's (for a less complicated situation) but they are also very funny! But, you guys have to post your own files ... I wouldn't do it for you ...

My DB (actually six DBs, and this is my first exposure to FM ever, did I take on a lot or what?) is gradually taking shape and I'd be happy to share its progress (and my ignorance) with whoever would like a look.

And now, it's Friday night, I am FRIED, and I am NOT going to risk any damage to my DBs by opening them, I am just going to read what you gurus have to say!

See you again soon (very soon!) - Bonnie wink.gif

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