Jump to content

Remember Child Rows For Set Of Parent Records


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

Recommended Posts

I have a layout with a portal with contacts and a second child portal for contact notes.

I would like to save the last child row that was selected for each contact and to be able to go back to that child row when a given contact is selected.

I am able to save the last child row visited by running a script trigger on OnObjectExit on the child portal.

Set Field[ Contacts:LastRowNumber ; Get(ActivePortalRow)]

I am able to retrieve the correct child note by attaching this script to the OnObjectEnter on the Contacts parent portal.

Go to Object [ Object Name: "NotesPortal" ]
Go to Portal Row[ Select; First ]
Loop
Set Variable [ $rowposition; Value:Get(ActivePortalRowNumber) ]
Exit Loop If [ T6b_list_CONTACTS_SELECTED::LastNotesRow = $rowposition ]
//Exit Loop If [ T6b_list_CONTACTS_SELECTED::LastNotesRow = Get(ActivePortalRowNumber) ]
Go to Portal Row
[ Select; Next; Exit after last ]
End Loop

Unfortunately, I can't run both scripts at the same time, the script that is attached to the child OnObjectExit applies the wrong value to the LastRownumber during the loop in the in the parent script. Is there a way to work around this or a different approach to do this?

Edited by laguna92651
Included script step by accident.
Link to comment
Share on other sites

Will this work if the parent portal and a child portal are on a layout from a third table. Can't seem to get it to work.

Also I would like the storage of the child row location to be permanent, so I can go to the remembered child row location when I re-open the application.

Link to comment
Share on other sites

Can you explain why you need this? It doesn't seem reasonable. To remember user selections across sessions, you would have to create a record in another table for every combination of user/parent.

I also see a timing problem here: when you switch to another record while a portal row is active, that portal row remains active. If you trigger your "remember" script OnObjectExit (why exit and not enter?), then the very act of switching to the remembered row will trigger the "remember" script and replace the remembered row with the current one. I don't see how this can work in the absence of an OnRecordExit script trigger.

 

3 hours ago, laguna92651 said:

the parent portal and a child portal are on a layout from a third table.

I could not understand this part. A parent portal?

Link to comment
Share on other sites

Well, I guess the only reason is that I wanted to pick up where I left off when I reopened the application. It sounds as though it is not that straight forward of a process.

I already know the two scripts I posted don't work together. The first script was originally on ObObjectEnter, but I moved it as I was trying to get things to work.

There are 3 tables, table 1 is the table the layout is based on, the second table is for the Contact portal (parent) and the third table is for the Notes portal (child), that are related to the Contact records on portal 2. It is the row on the Notes portal that I am trying to "remember."

Link to comment
Share on other sites

4 hours ago, laguna92651 said:

I wanted to pick up where I left off

Pick up what? Selecting a portal row is not significant of itself. At least it shouldn't be - and certainly not in long term. It's akin to positioning the cursor in a text field; you would want to preserve that while you're selecting a phrase to insert from a portal, for example - but not beyond that.

Link to comment
Share on other sites

By "pick up" I just meant being able to go to the same notes that had been selected in my last session, without scrolling to them again. I guess this isn't a big deal since most of the time the note list is short.

The example in the link you referenced doesn't scroll to the record that is "remembered" it just highlights it. So if the portal shows 10 records and the save record is the 15th record I still have to scroll down to see the highlighted record.

I can go with not "remembering" a record after a session is closed but I would like to visibly display the record in the child portal when record is selected in the parent portal while the session is open.

Link to comment
Share on other sites

2 hours ago, laguna92651 said:

The example in the link you referenced doesn't scroll to the record that is "remembered" it just highlights it.

It does more than just highlight it - it also shows the selected child record in a second, filtered portal. So it doesn't really matter if the originally clicked row remains visible or not - you can keep working on the selected record.

Anyway, it would be very simple to have a script triggered on OnRecordLoad re-select the remembered row. But you would either have to make the original selection manually (by clicking a button in the portal), or make sure that the "remember" script does not run when selection is made by the "restore" script.

Link to comment
Share on other sites

That is very nice, I hadn't notices the second portal before, thanks. That example will come in handy for something else.

How would I go about disabling the "remember" script, when the "restore" script runs?

Link to comment
Share on other sites

5 minutes ago, laguna92651 said:

Why did you want to "forget" the portal row number upon exiting the portal?

Well, when you deselect a portal row, then it should no longer be restored when you reload that record. At least that's the logic I would expect. But then I wouldn't use this mechanism at all (for reasons already stated), so it's not important.

Link to comment
Share on other sites

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