Jump to content
Sign in to follow this  
RSGC

Next Prev record in one row portal

Recommended Posts

Hi, I hope this has not been answered many times.

My (seemingly?) simple problem: I have a parent/child relationship, and in the vast majority of cases there will be only one child. But there will be cases when there are two, three, or more child records, and those need to be accommodated. The chance of the number of child records growing to a large number (more than 3 or 4) is VERY slim.

There are about 10 specific fields fields for each child, and a notes field. As in most cases it will be a 1 to 1, I am hoping to have a portal with all these fields for one record showing on my layout (like a little "standard layout" with the main layout). Then place buttons to do things, like add another child record, go to the next child record, go to the previous child record, etc.

I have the portal setup, and it is showing the appropriate first child record. And there are multiple child records created (if I delete one, the next in order shows up too!). I have tried two things for next/prev buttons so far:

1) I tried setting the buttons to the script step "Go To Portal Row Next" or "Go To Portal Row Previous" recognizing there was technically not another portal row to GOTO, hoping it would increment the record. It does not, at least how I have implemented it. Seemed simple, but no go.

2) I made a simple script "GotoChildNext" with the steps:

- Go to related record

- Go to Record Next

- Go to Layout Original Layout

Again, hoping for the best, but this is not incrementing the displayed record either.

I have the buttons "inside" the portal, thinking that would indicate to FMP which portal to affect.

BTW, I am on FMP 10 advanced at the moment.

Thanks for any pointers on this.

Bob

Share this post


Link to post
Share on other sites

Here's a basic sketch of how this could be done. Add buttons to bump N up/down to simulate a scroll.

Note:

This requires version 8 or higher.

ViewSelecteChild.fp7.zip

Share this post


Link to post
Share on other sites

Hi -- great solution. I have so much to learn. Sorry for the delayed response, just back to this project after too long a delay. As a follow up, what would be the best process to add a new child record. I have a button on the form that I can make work with a script that:

copies keyID form parent

switches to child form

new record

paste parent keyid into appropriate field

goto original layout

I do a couple other things in there, but is there a way to avoid the copy/paste that is not obvious to me. Unless I missed something there is no portal anymore (I know you had one on the example, but for simplicity of interface thinking I will eliminate that. I don't find a "create child record" script step, but maybe there is another way?

Thanks so much for your prompt and significant help!

Bob

Share this post


Link to post
Share on other sites

Copy and paste are frowned upon. You should use script variables or script parameter (also a form of a variable) to load the data you need, and the Set Field[] script step to put it where it belongs.

Share this post


Link to post
Share on other sites

Copy and paste are not suitable for tasks like this because the clipboard is under the control of the user, and this introduces risks and vulnerabilities into the process:

1) copy and paste require the fields to be on the current layout, which is not always possible or desirable;

2) the copy process destroys the current contents of the clipboard, which the user might have been relying on for their tasks

3) the user can change the clipboard at any time, and this may interfere with a filemaker process.

Imagine setting off a long script and putting FMP in the background while you do some work in another program. You copy some text to the clipboard... what will this do to the script running in the background?

Share this post


Link to post
Share on other sites

Hello -

I came here to learn about portals, and this is really helpful, but I have a question.

@comment Consultanta -

How do I create that Nth child table occurrence?

Thank you -

Marion

Share this post


Link to post
Share on other sites

Go to the relationships graph and click the "Add" (leftmost) button. Select the Child table, and name the occurrence "NthChild" (or whatever you like).

Share this post


Link to post
Share on other sites

Thank you -

I've always been intimidated by the idea of placing a 2nd occurrence of the same table...

2 parts are not working for me. Any idea what I'm doing wrong?

1. the value of N does not appear on my form (edit: I can get the field to show as 1, but not the subsequent records)

2. when I move my cursor from the first child record to the 2nd child record, the data on the right hand side doesn't change.

Also, I don't understand what the global field titled - is for or how it's used

Thank you -

Marion

Is the rectangle around the child record anything special? Or is it just a rectangular shape?

Edit: ahhh - there's a script going on in there. Maybe I can figure it out.

Edited by Guest

Share this post


Link to post
Share on other sites

I've always been intimidated by the idea of placing a 2nd occurrence of the same table...

Then you have been missing a very powerful feature.

Any idea what I'm doing wrong?

I'm afraid I cannot troubleshoot your file without seeing it (even if I wanted to ;) ).

Also, I don't understand what the global field titled - is for or how it's used

It's only a separator - it serves no real function in the demo.

Is the rectangle around the child record anything special? Or is it just a rectangular shape?

It's just a rectangle.

Share this post


Link to post
Share on other sites

Hi again

I created the script

I think the only piece of the puzzle I'm missing is how to get the script to run automatically - ie, in your sample file, it just works

I've attached the file - I'm working on the SHOW layout.

Can you see what I'm doing wrong or is that too much of an imposition?

Marion

detail_of_child_record.zip

Share this post


Link to post
Share on other sites

Try placing fields from the "Licnese 2" TO in the designated area?

BTW, I am not sure what you are trying to achieve here. If all you want is to view more details of the portal record, then this technique is not the best one - you'd better look at:

http://fmforums.com/forum/showtopic.php?tid/196128/

Share this post


Link to post
Share on other sites

Ok - I'll look at the other link

Thanks

I'm so overwhelmed.

I don't see how non-programmers can learn all this....

Share this post


Link to post
Share on other sites

That worked much better.

Now I need to surf and learn how to add a child record from this screen....

I read "You should use script variables or script parameter (also a form of a variable) to load the data you need, and the Set Field[] script step to put it where it belongs."

But I need a more explicit tutorial or example to follow.

Share this post


Link to post
Share on other sites

Hi to those that responded to my question. I appreciate the fact that using copy/paste is NOT a good idea, which is WHY I asked for other options. I have been using FMP for years, since the name was just Filemaker. but, unfortunately just casually, and script variables were not part of the product then, and their existence had slipped by me. I have used globals as sort of variables in the past, and did not think of their use for this. I will look into script variable and figure out what they are all about. Thanks!

Bob

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

Important Information

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